开发者

Country selection for a web form?

开发者 https://www.devze.com 2023-03-16 17:18 出处:网络
开发者_如何学编程How to create a HTML dropdown with list of countries , is there any web services which i can use ? without entering manual.You could use this jQuery plugin:

开发者_如何学编程How to create a HTML dropdown with list of countries , is there any web services which i can use ? without entering manual.


You could use this jQuery plugin: JQuery Autocomplete Plugin extension for country list


Get an array of country names like this one.

Then use this in your file:

<select name="countries">
<?php
$countries = array(
    'AF'=>'AFGHANISTAN',
    'AL'=>'ALBANIA',
    'DZ'=>'ALGERIA',
    'AS'=>'AMERICAN SAMOA',
    ...rest of data from site link above
);
foreach($countries as $key => $array) {
    ?><option value="<?=$key?>"><?=$value?></option>
}
</select>
?>

Explanation: Creates a array of country names, then goes through one at a time and writes each country name into an <option> within your <select></select> tags.

0

精彩评论

暂无评论...
验证码 换一张
取 消