I want to pass 2 variables in my php page to ajax page in onchange function. Actually this drop down box use in many pages. So I want to pass the page name to ajax page with the user selected value. How can I do that? Please help me..
This is my code.
ajax page
This is my code.
Code:
?>
<select name="Make" class="normalTxt" onChange='getMakeIndexPage(this.value); return false; ' id="Make" >
<option value="Select">Select</option>
<?php $mysql_result1 = mysql_query("SELECT DISTINCT vehicleMake FROM vehicles");
while($row = mysql_fetch_array($mysql_result1)){
foreach( $row AS $key => $val )
$Make = stripslashes( $val );
?>
<option value=<?php echo "'$Make'" ?> ><?php echo "$Make    "?>
<?php
}
?>
</option>
</select>
ajax page
Code:
function getMakeIndexPage(){
var dropdownIndex = document.getElementById('Make').selectedIndex;
var make = document.getElementById('Make')[dropdownIndex].value;
var request = GetXmlHttpObject();
var url="commonFunction.php";
url=url+"?make="+make+"&S=" +1;
//alert (url);
url=url+"&sid="+Math.random();
request.onreadystatechange=stateChanged;
request.open("GET",url,true);
request.send(null);
function stateChanged()
{
if (request.readyState==4)
{
document.getElementById("getMake").innerHTML=request.responseText;
}
}
}
Comment