sabecs
asked on
Build Select statement in Form from array using jQuery or PHP?
Hi,
My script below returns an array of countries and codes, can I build a select statement in a form from this array using jQuery or PHP?
My script below returns an array of countries and codes, can I build a select statement in a form from this array using jQuery or PHP?
Array ( [countries] => Array ( [country] => Array ( [0] => Array ( [code] => AF [name] => AFGHANISTAN ) [1] => Array ( [code] => AL [name] => ALBANIA ) [2] => Array ( [code] => DZ [name] => ALGERIA ) [3] => Array ( [code] => AS [name] => AMERICAN SAMOA ) [4] => Array ( [code] => AO [name] => ANGOLA ) [5] => Array ( [code] => AI [name] => ANGUILLA ) [6] => Array ( [code] => AG [name] => ANTIGUA AND BARBUDA ) ..
<script type="text/javascript">
var post_str = { url: "https://auspost.com.au/api/postage/country.json" };
$("#postage_costs").html('Getting Country List...');
$.ajax({
type: "POST", //define the type of ajax call (POST, GET, etc)
url: "../includes/auspost_api_countries.php", //The name of the script you are calling
data: post_str, //Your data you are sending to the script
success: function(msg){
alert (msg)
}
});
}
</script>
<form action="" method="post" name="coutry list">
<select name="select_country">
<option selected="selected">Please Select Country</option>
</select>
</form>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Glad to help. You might want to dig into this application a little bit more. In particular, this:
http://en.wikipedia.org/wiki/ISO_4217
Thanks for the points, ~Ray
http://en.wikipedia.org/wiki/ISO_4217
Thanks for the points, ~Ray
ASKER