Script Categories

Forms >>> Country.

If you'd like to know where visitors to your site live, add this to your feedback forms. They just choose a region, and the second menu changes appropriately, allowing them to choose their country. (If they choose USA, it allows them to select their state).

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- 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 -->
<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>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.

Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).