Forum Moderators: open
<script>
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e){
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}function getCity(strURL) {
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('mirkado').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}}
</script>
this my php query
<?php
$row = 5;
$col = 4;
for ($r=1; $r<=$row; $r++)
{
echo '<table>';
echo '<tr>';
?>
<td width="285" id="info" NOWRAP="NOWRAP"><table width="285" height="36" border="0">
<tr>
<td width="44" height="30" valign="top">
<select name="Market" onChange="getCity('GetPackType.php?GetMarker='+this.value)">
<option value="<?=$market?>">
<?=$market?>
</option>
<?php
echo selectProduction();
?>
</select></td>
<td width="231" valign="top"><div id="mirkado"></div></td>
</tr>
</table>
</td>
<?for ($c=1; $c <=$col; $c++)
{echo'<td><input type="text" size="6" name="col[]"></td>';
}
echo '</tr>';
echo '</table>';
}
?>
<div id="mirkado<?php echo $r; ?>">
Second you have to pass that ID to your javascript function so it knows which row you are working on:
onChange="getCity('GetPackType.php?GetMarker='+this.value, 'mirkado<?php echo $r; ?>')">
Finally, you have to update your function to receive the number parameter and to update the right element:
function getCity(strURL, elementId) {
document.getElementById(elementId).innerHTML=req.responseText;