我想在while循环中使用onchange从选择框中获取值。但我只得到第一个值。如何从所有人中获取价值?
我只是通过在 php 中使用 while 循环来做到这一点。
谁能告诉解决方案?
提前致谢。
这是我的代码:这是我的代码...
<script type="text/javascript">
function showUser1()
{
var str = document.getElementById("process").value;
var str1 = document.getElementById("snp").value;
alert(str);
alert(str1);
if (str=="")
{
document.getElementById("txtHint1").innerHTML="";
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("txtHint1").innerHTML=xmlhttp.responseText;
}
}
//xmlhttp.open("GET","process.php?q="+str,true);
xmlhttp.open("GET","process.php?q=" + str + "&q1=" + str1, true);
xmlhttp.send();
}
</script>
<table cellpadding="1" cellspacing="1" border="0">
<tr>
<td id="txtHint">
<table cellpadding="1" cellspacing="1" border="0">
<tr>
<th style="padding-left:500px;">Serial Number</th>
<th> Status</th></tr>
<tr>
<td>
<?php $i = 1;
while ($i <= 10) {
echo $i++; /* the printed value would be $i before the increment (post-increment) */
?>
<form>
<select name="process" id="process" onchange="showUser1(this.value)">
<option value="" selected="selected">Select</option>
<option value="0">Not Yet Start</option>
<option value="1">On Process...</option>
<option value="2">On Stock Yard</option>
<option value="3">Despatched</option>
</select>
<input type="text" name="snp" id="snp" value="<?php //echo $fetch['serial_number']; ?>" />
</form>
<?php } ?>
</td>
<td id="txtHint1"></td>
</tr>
</table>
</td>
</tr>
</table>