Created
November 26, 2013 19:32
-
-
Save PintuKumarPal/7664654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getState_add(countryId) | |
{ | |
ajax= nuevoAjax(); | |
var url="getstate_add.php"; | |
url=url+"?id="+countryId; | |
//alert(url); | |
ajax.open ("GET",url, true); | |
ajax.onreadystatechange= function() | |
{ | |
if (ajax.readyState == 4) | |
{ | |
//alert(ajax.responseText); | |
document.getElementById("getState").innerHTML = ajax.responseText; | |
var val = ajax.responseText; | |
} | |
} | |
ajax.send (null); | |
} | |
function nuevoAjax() | |
{ | |
var xmlhttp=false; | |
try | |
{ | |
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); | |
} | |
catch(e) | |
{ | |
try | |
{ | |
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
catch(E) | |
{ | |
xmlhttp=false; | |
} | |
} | |
if (!xmlhttp && typeof XMLHttpRequest!='undefined') | |
{ | |
xmlhttp=new XMLHttpRequest(); | |
} | |
return xmlhttp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_GET['id'])) | |
{ | |
$iCountryId = $_GET['id']; | |
$qState = mysql_query("select * from states where StateCtrCode= '$iCountryId' order by StateName desc"); | |
?> | |
<select name="ddState" id="ddState" class="just_textfield"> | |
<?php | |
while ($aState = mysql_fetch_array($qState)) | |
{?> | |
<option value="<?php echo $aState['StateCode'];?>"><?php echo $aState['StateName'];?></option> | |
<?php | |
} | |
?> | |
</select> | |
<?php } ?> | |
------------------- First Select box ----------- | |
<select name="ddCountry" id="ddCountry" class="just_textfield" onChange="getState_add(this.value)"> | |
<option value="0" selected="selected">Please select---</option> | |
<?php | |
$qGetCompanies = mysql_query("SELECT * FROM countries"); | |
while ($GetCompanies = mysql_fetch_array($qGetCompanies)) | |
{ | |
?> | |
<option value="<?php echo $GetCompanies['ctr_code']; ?>" <? if($GetCompanies['ctr_code'] == "US"){echo ' selected="selected"';}?><?php echo $GetCompanies['ctr_name']; ?></option> | |
<?php | |
} | |
?> | |
</select> | |
------------------- Second Select box ----------- | |
<?php | |
$sCountryCode = 'US'; | |
$sTempState = mysql_query("select * from states where StateCtrCode = '$sCountryCode'"); | |
?> | |
<select id="ddState" name="ddState" class="just_textfield" > | |
<?php | |
while ($aTempState = mysql_fetch_array($sTempState)) | |
{?> | |
<option value="<?php $aTempState['StateCode'];?>"><?=$aTempState['StateName'];?></option> | |
<?php }?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment