Hi,
I want to call two javascript functions which they are in a ajax file.These are populate Registration type and countries list. when I run this index file only PopulateCountry run and PopulateRegistration is not populateing the registrations type.
If I run only one function then its work fine but in case of both running only one function run properly.
Can any one help me.
------INDEX.PHP------
<html>
<head>
<script type="text/javascript">
function start()
{
PopulateRegistration();
PopulateCountry();
}
start();
</script>
</head>
<body >
<div id="wrap">
<!-- all code here-->
<div id="reg_type"></div>
<div id="country"></div>
</body>
</html>
------AJAX.JS--------
function GetXMLHttpObject()
{
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
alert("XMLHttpRequest not supported");
return null;
}
function PopulateRegistration()
{
alert("Registration");
xmlhttp=GetXMLHttpObject();
if (xmlhttp==null)
{
alert("Your Browser deos not Support XMLHTTP");
}
else
{
var url="populate_registration_type.php";
url=url + "?q=" + "®_type";
url=url + "&sid=" + Math.random();
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
// xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
xmlhttp.onreadystatechange=stateChangedRegistration;
}
}
function stateChangedRegistration()
{
if (xmlhttp.readyState==4 )
{
document.getElementById("reg_type").innerHTML=xmlhttp.responseText;
}
}
function PopulateCountry()
{
alert("Country");
xmlhttp=GetXMLHttpObject();
if (xmlhttp==null)
{
alert("Your Browser deos not Support XMLHTTP");
}
else
{
var url="populate_country.php";
url=url + "?q=" + "&country";
url=url + "&sid=" + Math.random();
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
// xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
xmlhttp.onreadystatechange=stateChangedCountry;
}
}
function stateChangedCountry()
{
if (xmlhttp.readyState==4 )
{
document.getElementById("country").innerHTML=xmlhttp.responseText;
}
}
-----Populate_reg_type.php-------
<?php
include "connection.php";
if (isset($_GET['reg_type']))
{
echo "<select name='catagory'>";
echo "<option>Select Catagory</option>";
$query="select info_code,info_desc from tblinfotype order by info_desc";
if (!($result=mysql_query($query,$objdbConnect->con))) die(mysql_error());
if (mysql_num_rows($result))
{
while(list($id, $name)=mysql_fetch_array($result))
{ echo "<option value=$id>$name</option> " ; }
}
echo "</select>";
}
?>
-----populte_country.php------
<?php
include "connection.php";
if (isset($_GET['country']))
{
echo "<select name='country' onchange='Populate(this.value)'>";
echo "<option>Select your Country</option>";
$query="select co_id,co_name from tblcountry order by co_name";
if (!($result=mysql_query($query,$objdbConnect->con))) die(mysql_error());
if (mysql_num_rows($result))
{
while(list($id, $name)=mysql_fetch_array($result))
{
echo "<option value=$id>$name</option> " ;
}
}
echo "</select>";
}
?>