如何使用一个ajax请求更改2个div?ajax,如何使用一个ajax请求更改两个div?
Ajax的update.php
<?php
include("config.inc.php");
include("user.inc.php");
$id = $_GET['id'];
$item = New item($id);
$result = $item->iteminfo;
echo $result->name."<br />";
unset($item);
?>
HTML:
<tr>
<td> (one) </td>
<td><input type="text" value="" onchange="showUser<?php echo $x;?>(this.value)" style="width:70px;"/></td>
<td><span id="txtHint<?php echo $x;?>"></span></td>
<td><input type="text" value="" name="price_<?php echo $x;?>" id="price_<?php echo $x;?>" onchange="upperCase<?php echo $x+$h;?>()" style="width:40px;"/></td>
<td><input type="text" id="proce_<?php echo $x;?>" style="width:70px;" value="<?php echo $x+$h;?>" disabled /></td>
<td><input type="text" value="" name="price_<?php echo $x;?>" style="width:40px;"/></td>
<td><input type='text' id="totalPrice<?php echo $x;?>" disabled /></td>
</tr>
脚本:
function showUser<?php echo $x;?>(str)
{
if (str=="")
{
document.getElementById("txtHint<?php echo $x;?>").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("txtHint<?php echo $x;?>").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax-update.php?id="+str,true);
xmlhttp.send();
}
我的问题是,当我改变这个值
<td><input type="text" value="" onchange="showUser<?php echo $x;?>(this.value)" style="width:70px;"/></td>
不仅如此TD
<td><span id="txtHint<?php echo $x;?>"></span></td>
而且这个TD
<td><input type="text" id="proce_<?php echo $x;?>" style="width:70px;" value="<?php echo $x+$h;?>" disabled /></td>
现在
我只能在飞行中改变一个DIV(txtHint),
索里,我的英语。
注: 我希望把未更新diferent文件, 例如当值的变化,这个脚本是字
xmlhttp.open("GET","ajax-update.php?id="+str,true);
,另一种是
foo.php
感谢
昂嘎
编辑1:
[1] | [2] | [3]
- [1]:I输入值manualy
- [2]:这个跨度txtHint变化使用AJAX
- [3]:我想这种变化过于同[2]
编辑2:
document.getElementById("txtHint<?php echo $x;?>").innerHTML=xmlhttp.responseText;
document.getElementById("proce_<?php echo $x;?>").value=xmlhttp.responseText;
这就是是工作,但 值在[2]和[3]是相同的,因为它从一个文件Ajax的update.php取如何添加其他文件,但仍然在一个Ajax请求?
在你的问题的第一句话中,你说你想改变divs,但实际上你只是在谈论问题结尾提到的td元素,对吧? – SharpKnight
yap。 td只是为了掩护,我想把其他div放在td里面。 sory如果我的问题或我的英语很混乱。 – Anggagewor