|
|
|
แก้ปัญหาบันทึก radio button กับ ajax ไม่ได้คับ ผมจะบันทึก การเลือก radiobutton ไม่ได้คับ |
|
|
|
|
|
|
|
ผมจะบันทึก การเลือก radiobutton ไม่ได้คับ
Code (PHP)
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Mode,ID) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try { HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try { HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'query.php';
if (Mode=="UPDATE"){
var Male=document.getElementById('Male');
var Female=document.getElementById('Female');
if (Male.checked) {
sex = Male.value;
} else if (Female.checked) {
sex = Female.value;
}
var A=document.getElementById('A');
var B=document.getElementById('B');
var AB=document.getElementById('AB');
var O=document.getElementById('O');
if (A.checked) {
blood = A.value;
} else if (B.checked) {
blood = B.value;
}else if (AB.checked) {
blood = AB.value;
}else if (O.checked) {
blood = O.value;
}
var pmeters = "Mode=" + Mode + "&ID=" + encodeURI( document.getElementById("id").value ) +
"&name=" + encodeURI( document.getElementById("name").value ) +
"&nickname=" + encodeURI( document.getElementById("nickname").value ) +
"&tel=" + encodeURI( document.getElementById("tel").value ) +
"&email=" + encodeURI( document.getElementById("email").value ) +
"&sex="+ (sex) +
"&address=" + encodeURI( document.getElementById("address").value ) +
"&blood="+ (blood) +
"&province=" + encodeURI( document.getElementById("province").value );
}
else if (Mode == "ADD" ){
var Male=document.getElementById('Male');
var Female=document.getElementById('Female');
if (Male.checked) {
sex = Male.value;
} else if (Female.checked) {
sex = Female.value;
}
var A=document.getElementById('A');
var B=document.getElementById('B');
var AB=document.getElementById('AB');
var O=document.getElementById('O');
if (A.checked) {
blood = A.value;
} else if (B.checked) {
blood = B.value;
}else if (AB.checked) {
blood = AB.value;
}else if (O.checked) {
blood = O.value;
}
var pmeters = "name=" + encodeURI( document.getElementById("name").value) +
"&nickname=" + encodeURI( document.getElementById("nickname").value ) +
"&tel=" + encodeURI( document.getElementById("tel").value ) +
"&sex="+ (sex) +
"&email=" + encodeURI( document.getElementById("email").value ) +
"&address=" + encodeURI( document.getElementById("address").value ) +
"&province=" + encodeURI( document.getElementById("province").value ) +
"&blood=" + encodeURI( document.getElementById("blood") ) +
"&blood="+ (blood) +
"&Mode=" + Mode;
}
else{
var pmeters = "Mode=" + Mode + "&ID=" + ID;
}
if(Mode == "LIST")
{
var pmeters = "";
}
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("myForm").style.display = 'none';
document.getElementById("name").value = '';
document.getElementById("nickname").value = '';
document.getElementById("address").value = '';
document.getElementById("tel").value = '';
document.getElementById("email").value = '';
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
function ShowEdit(id,name,tel,email,nickname,address,sex,province,blood)
{
document.getElementById("myForm").style.display = '';
document.getElementById("id").value=id;
document.getElementById("name").value=name;
document.getElementById("tel").value=tel;
document.getElementById("email").value=email;
document.getElementById("nickname").value=nickname;
document.getElementById("address").value=address;
document.getElementById("sex").value=sex;
document.getElementById("province").value=province;
document.getElementById("blood").value=blood;
alert(blood);
}
</script>
Code (PHP)
<input name="sex" type="radio" id="Male" value="ชาย" />
ชาย
<input name="sex" type="radio" id="Female" value="หญิง" />
หญิง
Tag : - - - -
|
|
|
|
|
|
Date :
2010-01-26 04:24:06 |
By :
nammont |
View :
1667 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|