하나의 아약스 요청을 사용하여 2 개의 div를 변경하는 방법은 무엇입니까?아약스, 하나의 아약스 요청을 사용하여 두 div를 변경하는 방법?
아약스 - 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>
뿐만 아니라 나는 단지 즉석에서 하나의 DIV (txtHint)를 변경할 수 있습니다 지금
<td><input type="text" id="proce_<?php echo $x;?>" style="width:70px;" value="<?php echo $x+$h;?>" disabled /></td>
이 TD, 내 영어에 대한
sory .
참고 : 내가 값 변경은,이 스크립트는 단어
xmlhttp.open("GET","ajax-update.php?id="+str,true);
이고 다른 하나는
foo.php
감사
때, 예를 들어, 개의 다른 파일 을 취소 업데이 트를 데려 가고 싶다는angga
EDIT 1 :
[1] | [2] | [3]
- [1] : I 입력 값을 수동으로 실시
- [2]이 범위 txtHint 변경하여 AJAX
- [3] I [2]
EDIT 2
document.getElementById("txtHint<?php echo $x;?>").innerHTML=xmlhttp.responseText;
document.getElementById("proce_<?php echo $x;?>").value=xmlhttp.responseText;
그게는 직장, 그러나 값은 [2]는 하나 개의 파일 에이잭스 update.php 01,235 걸릴 때문에 [3] 동일한하나의 아약스 요청에 다른 파일을 추가하는 방법은 무엇입니까?
질문의 첫 문장에서 div를 변경하고 싶지만 질문 끝에 언급 된 td 요소에 대해서만 이야기하는 것입니다. 맞습니까? – SharpKnight
td는 표지 용으로, 나는 다른 div를 td 안에 넣고 싶다. 내 질문이나 영어가 혼란 스럽다면 sory. – Anggagewor