user ajax onchange select box pass the value of select
HTML
<selectname="sometest"onchange="javascript:call_ajax_fun(this.value);"><optionvalue="1"> A </option><optionvalue="2"> B </option><optionvalue="3"> C </option><optionvalue="4"> D </option><optionvalue="5"> E </option></select>
JS Ajax Function
functioncall_ajax_fun(str)
{
if (window.XMLHttpRequest)
{
xmlhttp=newXMLHttpRequest();
}
else
{
xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var result = xmlhttp.responseText;
if(xmlhttp.responseText!='')
{
document.getElementById('your_result_div_id').innerHTML =result ;
}
}
}
var url="get_result.php?pas_val="str;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
and your get result file will be as follows
get_result.php
<?phpif(isset($_REQUEST['pas_val']))
{
$pas_val = $_REQUEST['pas_val'];
if($pas_val<5)
{
$tbl = "table_1";
}
else
{
$tbl = "table_2";
}
}
else
{
exit;
}
?>
Post a Comment for "Onchange Dropdown Values Query Resp. Tables - With Php , Mysql , Ajax , Jquery"