嗨我試圖將我的HTML/PHP/JS/XML頁面遷移到一個PHP文件。我能夠單獨成功地使用4個文件創建我的應用程序,但是當我將它們放入一個時,似乎我的js和php處於衝突狀態,並且如果有方法我可以使單選按鈕默認設置爲無選項,因爲我猜猜這就是問題所在。如何阻止一個PHP頁面重新加載並重新加載其屬性?
嗯,我已經解決了有關單選按鈕的問題,無論如何,我試圖讓他們都在一個頁面上,因爲我試圖模仿本地程序的輸出,我意識到這一個,當我看到輸出我第一次嘗試。所以我現在想要做的是在運行php代碼後我想把它們放在一個div中,這樣它們就不會飛到所有的地方。我已經解決了這個部分,但我現在的問題是當我選擇我的選項中的下一個單選按鈕時,先前請求的結果仍然存在,除非我單擊我的提交按鈕。我猜測它與我傳遞給我的html正文的js有關。試圖在js中修復div問題是可以的,但它只是在一瞬間顯示div。
這裏是我的代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Globe2Smac</title>
<link rel="stylesheet" href="css/mycss.css" type="text/css">
<script src="js/hide.js" type="text/javascript"></script>
</head>
<body onLoad="">
<h2>Globe to SMAC Function</h2>
<form method="post" action="">
<div>
<ul style="list-style:none">
<li><input id="smember" type ="radio" name ="option" value = "SmacMembers" onChange="SMmember()" checked/>SMAC MEMBERS</li>
<li><input id="sbalance"type ="radio" name ="option" value = "SmacBalance" onChange="SMbalance()" checked/>SMAC BALANCE QUERY</li>
<li><input id="saward" type ="radio" name ="option" value = "SmacAward" onChange="SMaward()" checked/>SMAC AWARD</li>
<li><input id="sredemption" type ="radio" name ="option" value = "SmacRedeem" onChange="SMredeem()" checked/>SMAC REDEMPTION</li>
</ul>
<div>Globe XML RPC Request:</div>
<div id="smmember" class="div-border" style="display:none"><textarea id="areamember" name="gmember" value="Member" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.members</methodName>
<params>
<param>
<value>
<string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_members&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521960565&lt;/cardnumber&gt;
&lt;transaction_id&gt;12345678&lt;/transaction_id&gt;
&lt;/globetosmac&gt;
</string>
</value>
</param>
</params>
</methodCall></textarea></div>
<div id="smbalancequery"class="div-border" style="display:none"><textarea id="areabalance" name="gbalance" value="Balance" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.balance_query</methodName>
<params>
<param><value><string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_balance_query&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521960565&lt;/cardnumber&gt;
&lt;transaction_id&gt;1441795&lt;/transaction_id&gt;
&lt;birthday&gt;01011900&lt;/birthday&gt;
&lt;transactiondatetime&gt;2011-09-16 13:43:58&lt;/transactiondatetime&gt;
&lt;/globetosmac&gt;
</string></value></param>
</params>
</methodCall>
</textarea></div>
<div id="smaward" class="div-border"style="display:none"><textarea id="areaward" name="gaward" value="Award" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.award_points</methodName>
<params>
<param>
<value>
<string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_award_points&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521060440&lt;/cardnumber&gt;
&lt;transaction_id&gt;1441795&lt;/transaction_id&gt;
&lt;transaction_amount&gt;100&lt;/transaction_amount&gt;
&lt;transaction_code&gt;OFLN-GLOBE&lt;/transaction_code&gt;
&lt;transactiondatetime&gt;2011-09-22 16:20:58&lt;/transactiondatetime&gt;
&lt;/globetosmac&gt;
</string>
</value>
</param>
</params>
</methodCall></textarea></div>
<div id="smredemption" class="div-border"style="display:none"><textarea id="arearedeem" name="gredeem" value="Redeem" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.redemption_points</methodName>
<params>
<param>
<value>
<string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_redemption_points&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521060440&lt;/cardnumber&gt;
&lt;transaction_id&gt;1441795&lt;/transaction_id&gt;
&lt;transaction_amount&gt;10&lt;/transaction_amount&gt;
&lt;transaction_code&gt;OFLN-GLOBE&lt;/transaction_code&gt;
&lt;transactiondatetime&gt;20110921 16:20:58&lt;/transactiondatetime&gt;
&lt;/globetosmac&gt;
</string>
</value>
</param>
</params>
</methodCall></textarea></div>
<div id="submit"><input type="submit" name="Submit" value="Submit Query"></div>
<div>Globe XML Response:</div>
<div class="div-border"><?php
if($_POST['option'] == "SmacMembers"){
$member = $_POST['gmember'];
$URL = 'https://localhost/globe2smac-fh3/api/';
$ch = curl_init($URL);
//curl_setopt($ch, CURLOPT_URL, "https://localhost/globe2smac-fh3/api");
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/html'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $member);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 2);
$MemResult = curl_exec($ch);
curl_close($ch);
}
else if($_POST['option'] == "SmacBalance"){
$balance= $_POST['gbalance'];
echo $balance;
$URL = "https://localhost/globe2smac-fh3/api/";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$balance");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$BalResult= curl_exec($ch);
curl_close($ch);
echo $output;
}
else if($_POST['option'] == "SmacAward"){
$award=$_POST['gaward'];
echo $award;
$URL = "https://localhost/globe2smac-fh3/api/";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$award");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
else if($_POST['option'] == "SmacRedeem"){
$redeem=$_POST['gredeem'];
echo $redeem;
$URL = "https://localhost/globe2smac-fh3/api/";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$redeem");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$RedResult = curl_exec($ch);
curl_close($ch);
echo $output;
}
else{
echo('Option not Found');
}
?></div>
</div>
</form>
</body>
</html>
重新更新了我的代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Globe2Smac</title>
<link rel="stylesheet" href="css/mycss.css" type="text/css">
<script src="js/hide.js" type="text/javascript"></script>
</head>
<body onLoad="siteLoad();">
<h2>Globe to SMAC Function</h2>
<form method="post" action="">
<div>
<ul style="list-style:none">
<li><input id="smember" type ="radio" name ="option" value = "SmacMembers" onChange="SMmember()" />SMAC MEMBERS</li>
<li><input id="sbalance"type ="radio" name ="option" value = "SmacBalance" onChange="SMbalance()"/>SMAC BALANCE QUERY</li>
<li><input id="saward" type ="radio" name ="option" value = "SmacAward" onChange="SMaward()"/>SMAC AWARD</li>
<li><input id="sredemption" type ="radio" name ="option" value = "SmacRedeem" onChange="SMredeem()"/>SMAC REDEMPTION</li>
</ul>
<div>Globe XML RPC Request:</div>
<div id="smmember" class="div-border" style="display:none"><textarea id="areamember" name="gmember" value="Member" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.members</methodName>
<params>
<param>
<value>
<string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_members&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521960565&lt;/cardnumber&gt;
&lt;transaction_id&gt;12345678&lt;/transaction_id&gt;
&lt;/globetosmac&gt;
</string>
</value>
</param>
</params>
</methodCall></textarea></div>
<div id="smbalancequery"class="div-border" style="display:none"><textarea id="areabalance" name="gbalance" value="Balance" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.balance_query</methodName>
<params>
<param><value><string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_balance_query&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521960565&lt;/cardnumber&gt;
&lt;transaction_id&gt;1441795&lt;/transaction_id&gt;
&lt;birthday&gt;01011900&lt;/birthday&gt;
&lt;transactiondatetime&gt;2011-09-16 13:43:58&lt;/transactiondatetime&gt;
&lt;/globetosmac&gt;
</string></value></param>
</params>
</methodCall>
</textarea></div>
<div id="smaward" class="div-border"style="display:none"><textarea id="areaward" name="gaward" value="Award" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.award_points</methodName>
<params>
<param>
<value>
<string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_award_points&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521060440&lt;/cardnumber&gt;
&lt;transaction_id&gt;1441795&lt;/transaction_id&gt;
&lt;transaction_amount&gt;100&lt;/transaction_amount&gt;
&lt;transaction_code&gt;OFLN-GLOBE&lt;/transaction_code&gt;
&lt;transactiondatetime&gt;2011-09-22 16:20:58&lt;/transactiondatetime&gt;
&lt;/globetosmac&gt;
</string>
</value>
</param>
</params>
</methodCall></textarea></div>
<div id="smredemption" class="div-border"style="display:none"><textarea id="arearedeem" name="gredeem" value="Redeem" spellcheck="false">
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>smac.redemption_points</methodName>
<params>
<param>
<value>
<string>
&lt;?xml version="1.0"?&gt;
&lt;globetosmac&gt;
&lt;functioncode&gt;smac_redemption_points&lt;/functioncode&gt;
&lt;cardnumber&gt;8880999521060440&lt;/cardnumber&gt;
&lt;transaction_id&gt;1441795&lt;/transaction_id&gt;
&lt;transaction_amount&gt;10&lt;/transaction_amount&gt;
&lt;transaction_code&gt;OFLN-GLOBE&lt;/transaction_code&gt;
&lt;transactiondatetime&gt;20110921 16:20:58&lt;/transactiondatetime&gt;
&lt;/globetosmac&gt;
</string>
</value>
</param>
</params>
</methodCall></textarea></div>
<div id="submit"><input type="submit" name="Submit" value="Submit XML Request"></div>
<div>Globe XML Response:</div>
<div class="div-border"><?php
if($_POST['option'] == "SmacMembers"){
$member = $_POST['gmember'];
$URL = 'https://localhost/globe2smac-fh3/api/';
$ch = curl_init($URL);
//curl_setopt($ch, CURLOPT_URL, "https://localhost/globe2smac-fh3/api");
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/html'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $member);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 2);
$MemResult = curl_exec($ch);
curl_close($ch);
echo $MemResult;
}
else if($_POST['option'] == "SmacBalance"){
$balance= $_POST['gbalance'];
$URL = "https://localhost/globe2smac-fh3/api/";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$balance");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$BalResult= curl_exec($ch);
curl_close($ch);
echo $BalResult;
}
else if($_POST['option'] == "SmacAward"){
$award=$_POST['gaward'];
echo $award;
$URL = "https://localhost/globe2smac-fh3/api/";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$award");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$Awresult= curl_exec($ch);
curl_close($ch);
echo $Awresult;
}
else if($_POST['option'] == "SmacRedeem"){
$redeem=$_POST['gredeem'];
echo $redeem;
$URL = "https://localhost/globe2smac-fh3/api/";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "michael:kel");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$redeem");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$RedResult = curl_exec($ch);
curl_close($ch);
echo $RedResult;
}
else{
echo('Processing Requests...');
}
?></div>
</div>
</form>
</body>
</html>
刪除'checked'屬性?對不起,我不清楚是什麼問題 –