choose your country

Written by @kerixa 21 August 2012

A drop-down list is used to fill out various forms on the websites. In the following code, a dropdown list is provided for selecting a country. This country list is filtrable, which means you can search in it, and also uses beautiful colors.

Code Snippet:

                                                <!-- this script is provided by coded by: Kerixa Inc. -->
<!-- This Script is from, Coded by: Krishna Eydat-->



<!-- Begin
var africaArray =  new Array("('Select country','',true,true)",
"('South Africa')",
var middleeastArray =  new Array("('Select country','',true,true)",
"('Saudi Arabia')",
"('U. A. Emirates')",
var asiaArray =  new Array("('Select country','',true,true)",
"('South Korea')",
"('Sri Lanka')",
var europeArray =  new Array("('Select country','',true,true)",
"('Czech Rep.')",
"('United Kingdom')",
var australiaArray =  new Array("('Select country','',true,true)",
"('New Zealand')",
var lamericaArray =  new Array("('Select country','',true,true)",
"('Costa Rica')",
"('El Salvador')",
var namericaArray =  new Array("('Select country','',true,true)",
var samericaArray =  new Array("('Select country','',true,true)",
function populateCountry(inForm,selected) {
var selectedArray = eval(selected + "Array");
while (selectedArray.length < {[( - 1)] = null;
for (var i=0; i < selectedArray.length; i++) {
eval("[i]=" + "new Option" + selectedArray[i]);
if (inForm.region.options[0].value == '') {
inForm.region.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
else {   	
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
function populateUSstate(inForm,selected) {  
var stateArray =  new Array("('Select State','',true,true)",
"('New Hampshire')",
"('New Jersey')",
"('New Mexico')",
"('New York')",
"('North Carolina')",
"('North Dakota')",
"('Rhode Island')",
"('South Carolina')",
"('South Dakota')",
"('West Virginia')",
if (selected == 'USA') {
for (var i=0; i < stateArray.length; i++) {
eval("[i]=" + "new Option" + stateArray[i]);
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
else {    	
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
else {
if (selected == 'Other') {
newCountry = "";
while (newCountry == ""){
newCountry=prompt ("Please enter the name of your country.", "");
if (newCountry != null) {[(]=new Option(newCountry,newCountry,true,true);[]=new Option('Other, not listed','Other');
if([0].text == 'Select country') {[0]= null;
// End -->

<!-- CCONTINUE  -->


<form name="globe">
<select name="region" onChange="populateCountry(document.globe,document.globe.region.options[document.globe.region.selectedIndex].value)">
<option selected value=''>Select Region</option>
<option value='asia'>Asia</option>
<option value='africa'>Africa</option>
<option value='australia'>Australia</option>
<option value='europe'>Europe</option>
<option value='middleeast'>Middle East</option>
<option value='lamerica'>Latin America</option>
<option value='namerica'>North America</option>
<option value='samerica'>South America</option>
<select name="country" onChange="populateUSstate(document.globe,[].text)">
<option value=''><--------------------</option>
<br />
<font face="Tahoma"><a target="_blank" href=""><span style="font-size: 8pt; text-decoration: none">HTML Free Code</span></a></font><a target='_blank' href='' style='font-size: 8pt; text-decoration: none'>Html Free Codes</a>                                                


About @kerixa

I am Krishna Eydat. I studied Software Engineering at University of Waterloo in Canada. I lead a few tech companies. I am passionate about the way we are connected. I would like to be part of something big or be the big deal!



Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

Online Users: 12
Recent Members: Prashanthcs11, Designer Diva, Jirgensons E, vamsi, wapmohin
advertisement 2