ok- that makes sense - you need a javascript forum!
you need to pass that variable along with the call to the ajax
here's one I bodged earlier
first add bits to your onChange in the originating select
onchange="drawdrop(this.value,<?php echo $editid;?>,'levdiv1',<?php echo $txsect ?> );"
this.value is selected valued
editid is the item being edited
levdiv1 is the div I want to update
txsect is like topcity - something else I want pass around..
then pick those up in the ajax/javascript |: incomplete code..
- javascript:
function drawdrop(str,othvar,outputdiv,txsect)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
opdiv=outputdiv;
//if (str==0)return;
var url="fetch_ajdd.php";
url=url+"?itmid="+str;
url=url+"&editid="+othvar;
url=url+"&txsect="+txsect;
url=url+"&sid="+Math.random();
//alert (url);
// uncomment line above for testing!
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
// alert ("aaa"+opdiv);
if (xmlHttp.readyState==4)
{
switch (opdiv)
{
case 'levdiv1':
document.getElementById("levdiv1").innerHTML=xmlHttp.responseText;
break;
}
}
}
so I added 'othvar' and 'opdiv'
othvar gets appended to the query string that gets pased to the php fetch script
the value of opdiv tells the function to do something else for one specific div - though I cant remember why I did that right now
in my php fetch script add at top
$itmid = $_GET['itmid'];
$editid = $_GET['editid'];
$txsect = $_GET['txsect'];
and you can do what you like with those values
that make sense?