PDA

View Full Version : مشکل این کد کجاست که مقدار ارسال نمیشه؟؟؟؟؟؟؟؟؟؟؟؟؟؟



ms11309
دوشنبه 06 مرداد 1393, 12:36 عصر
سلام دوستان

یه چک باکس در فرم به شکل زیر دارم




<input type="checkbox" id="type" name="type">



مقادیر با جاوا اسکریپت ارسال میشه




function connect(url,data,id,load) {
var xmlhttp=false;

if(!xmlhttp) {
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else if (window.ActiveXObject)
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
} else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState==4 && xmlhttp.status == 200) {
document.getElementById(id).innerHTML = xmlhttp.responseText;
}else if (xmlhttp.readyState==0 || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3) {
document.getElementById(id).innerHTML = load;
} else {
document.getElementById(id).innerHTML = note;
}
}
xmlhttp.send(data);
}
function refresh() {
reimg=document.getElementById('re')
reimg.src = reimg.src;
}

var form_load = "";


function Send() {
type = document.getElementById("type").value;

connect('/send.php',"type="+type,"result",form_load);
}






و در فایل php اینطور نوشتم



if(isset($_REQUEST['type'])){
$type = "e";
} else {
$type = "c";
}


ولی خروجی چه در صورت تیک خوردن چک باکس چه خالی بودنش e هستش
مشکل کجاست و باید چه کار کنم؟
ممنون

ms11309
دوشنبه 06 مرداد 1393, 13:08 عصر
لطفا یکی جواب بده
خیلی ضروریه

MoMo121
دوشنبه 06 مرداد 1393, 14:02 عصر
کد جاوا اسکریپتت رو باید به این تغییر بدی

function Send() {var type = document.getElementById("type").checked;

connect('/send.php',"type="+type,"result",form_load);
}