有好几个checkbox循环出来,还有个文本框<input name="ckID[]" type="checkbox" id="<?='ckID'.$row['MIS_id']?>" value="<?=$row['MIS_id']?>" onclick="showInfor(this.value)" />
<div id="txtHint">
<input name="txtid" type="text" id="txtid" />
</div>
以下是AJAX:function showInfor(str) {
//document.getElementById("txtid").value=str;
//var str = document.geElementById("ckID").value;
//document.write(str);
var xmlhttp;
if (id.length==0)
{
document.getElementById("txtid").value="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//document.getElementById("show").innerHTML=xmlhttp.responseText;
document.getElementById("txtid").value=xmlhttp.responseText;
}
}
xmlhttp.open("GET","showSettle.php?q="+str,true);
xmlhttp.send();
}然后是对于的php页面$db = mysql_connect("localhost","root","1234");
mysql_select_db("it database",$db);$q=$_GET['q']; // connecting to database and stuff...
echo $q;
$temp = mysql_query("SELECT MIS_id FROM materialinstorage WHERE MIS_id = '$q' ");
echo $temp;$row = mysql_fetch_array($temp);
$id =$row['MIS_id'];
echo $id;
现在好像是php那页面不执行,没反应啊。
我在ajax里执行document.write(str);可以得到数据的。
请问哪里出错了呀
<div id="txtHint">
<input name="txtid" type="text" id="txtid" />
</div>
以下是AJAX:function showInfor(str) {
//document.getElementById("txtid").value=str;
//var str = document.geElementById("ckID").value;
//document.write(str);
var xmlhttp;
if (id.length==0)
{
document.getElementById("txtid").value="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//document.getElementById("show").innerHTML=xmlhttp.responseText;
document.getElementById("txtid").value=xmlhttp.responseText;
}
}
xmlhttp.open("GET","showSettle.php?q="+str,true);
xmlhttp.send();
}然后是对于的php页面$db = mysql_connect("localhost","root","1234");
mysql_select_db("it database",$db);$q=$_GET['q']; // connecting to database and stuff...
echo $q;
$temp = mysql_query("SELECT MIS_id FROM materialinstorage WHERE MIS_id = '$q' ");
echo $temp;$row = mysql_fetch_array($temp);
$id =$row['MIS_id'];
echo $id;
现在好像是php那页面不执行,没反应啊。
我在ajax里执行document.write(str);可以得到数据的。
请问哪里出错了呀
我把ajax里的id.length==0改成了xmlhttp==null
可效果还是一样的,状态栏里也没显示网页错误了
这个 id 没有定义
document.getElementById('...')为空或不是对象document.getElementById("txtid").value="";应该是这句,这是什么错啊
if (id.length==0){ //是这段的处理,主要是id.length这个没有定义,不懂这段做什么,是判断复选框是否被选? 检查下这段
document.getElementById("txtid").value="";
return;
}
document.getElementById("txtid").value="";
return;
}