在ajax中发送复选框值。
复选框值未发布到php,此后整个脚本无法正常工作。 请有人告诉我我在哪里犯了错误并为此提供了解决方案。
function ajaxFunction(str,str1,str2,str3)
{
var security = $('input[name="subfolder"]').prop('checked');
var httpxml;
try
{
// Firefox, Opera 8.0+, Safari
httpxml=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
httpxml=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httpxml=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
function stateChanged()
{
if(httpxml.readyState==4)
{
document.getElementById("displayDiv").innerHTML=httpxml.responseText;
}
}
var url="my-test-search.php";
url=url+"?txt="+str+"&txt1="+str1+"&txt2="+str2+"&txt3="+str3+"&che="+security;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateChanged;
httpxml.open("GET",url,true);
httpxml.send(null);
}
<form id="myform" method="post">
Search : <input type="text" id="search_text" name="search_text" size="44" >
Extension : <input type="text" id="search_extension" name="search_extension" size="4" maxlength="4"> <br><br>
Include Sub Files <input type="checkbox" id="subfolder" name="subfolder" value="0">
LTO-No. <input type="text" id="search_ltono" name="search_ltono" size="4" maxlength="4">
<input name="buttonExecute" onclick="ajaxFunction(search_text.value,search_ltono.value,search_extension.value,subfolder.value)" type="button" value="Show " />
</form>
答案 0 :(得分:0)
复选框没有属性值,但已检查属性。尝试使用:
subfolder.checked
并从标记中删除属性值