Enjoy an ad free experience by logging in. Not a member yet?
Register .
02-20-2003, 08:02 PM
PM User |
#1
New Coder
Join Date: Jun 2002
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
I need a "Country's State" code
Hi there.
I have a form to compile my user's information, in this form I have a field "Country" and a field "State", what I'm looking for is a script that displays the list of the states in the "State" field depending on what country has being selected.
I know is not that hard to develop, but I dont know every State of many Countries, so what I really want from that script is the list of the states of several countries.
If any one have any idea whre to find it please tellme
Thanx
02-20-2003, 08:53 PM
PM User |
#2
Regular Coder
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
I've got something like that:
Will show the states if USA is picked, but not other countries.
Last edited by Quiet Storm; 02-20-2003 at 10:49 PM ..
02-20-2003, 10:27 PM
PM User |
#3
New Coder
Join Date: Jun 2002
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Thanx, but actually I'm looking for the list of states-contries, most of all...
But thanx any way
02-20-2003, 10:55 PM
PM User |
#4
Regular Coder
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
I picked this example off of the net somewhere. You'd have to fill in all the details, though.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<h1 align="center">Select a country and a state. </h1>
<div align="center">
<form name="form1">
<p><b>Country</b>
<select name="select" size="1" onChange="pop2();">
<option selected>Australia</option>
<option>USA</option>
<option>Canada</option>
</select>
</p>
<p> <b>State</b>
<select name="select2">
<option selected>NSW</option>
<option>Victoria</option>
<option>Queensland</option>
<option>South Australia</option>
<option>Tasmania</option>
<option>Western Australia</option>
</select>
</p>
</form>
</div>
</body>
</html>
<SCRIPT language="javascript">
function pop2() {
var currentlength = window.document.form1.select2.length
for (var i=0; i < currentlength; i++) {
window.document.form1.select2.options[0] = null
}
if (window.document.form1.select.selectedIndex == 0) {
window.document.form1.select2.options[0] = new Option('aussiestate1');
window.document.form1.select2.options[1] = new Option('aussiestate2');
}
if (window.document.form1.select.selectedIndex == 1) {
window.document.form1.select2.options[0] = new Option('USstate1');
window.document.form1.select2.options[1] = new Option('USstate2');
}
if (window.document.form1.select.selectedIndex == 2) {
window.document.form1.select2.options[0] = new Option('canadastate1');
window.document.form1.select2.options[1] = new Option('canadastate2');
}
}
</SCRIPT>
02-20-2003, 11:01 PM
PM User |
#5
wei wu wei
Join Date: Jun 2002
Location: 72° W. 48' 57" , 41° N. 32' 04"
Posts: 1,887
Thanks: 0
Thanked 1 Time in 1 Post
02-20-2003, 11:01 PM
PM User |
#6
Regular Coder
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Here's another one - may be easier to configure:
<html>
<head></head>
<script language="javascript">
<!--
var USA_Array = new Array();
var Sri_Array = new Array();
var China_Array = new Array();
USA_Array[0] = "AL";
USA_Array[1] = "AK";
USA_Array[2] = "AZ";
USA_Array[3] = "AR";
Sri_Array[0] = "CL";
Sri_Array[1] = "GN";
Sri_Array[2] = "MK";
China_Array[0] = "SH";
China_Array[1] = "HK";
function pop(){
var array;
if(document.form.country[document.form.country.selectedIndex].value == 1)
array = USA_Array;
else if(document.form.country[document.form.country.selectedIndex].value == 2)
array = Sri_Array;
else
array = China_Array;
for(i=0;i<array.length;i++)
document.form.state.options[i] = new Option(array[i],array[i]);
document.form.state.reset;
document.form.state.selectedIndex=0;
}
//-->
</script>
<body>
<form name="form">
<select name="country" onchange="pop()">
<option value="None">--- select ---
<option value="1">USA
<option value="2">Srilanka
<option value="3">China
</select>
<select name="state">
<option value="None">--- select ---
</select>
</form>
</body>
</html>
02-20-2003, 11:11 PM
PM User |
#7
New Coder
Join Date: Jun 2002
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
thnx for the tip
Thnx for the tip joh6nn but I knew that usefull tool already...
but thnx any way I guess I'll have to write it all by myself
02-22-2003, 08:12 PM
PM User |
#8
Regular Coder
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
I got to thinking about this, and think it would be a real neat idea to have cities of different countries (not just the US). I've started a little something with the code I posted above:
http://www.angelfire.com/mo2/cbch21/...itySelect.html
Cities for Algeria, Angola, Argentina, Australia, Brazil, Canada, French Polynesia, and the US states are all I have up so far... out of 241 countries.
Good idea, thanks for posting this question - made me think.
02-22-2003, 10:11 PM
PM User |
#9
Regular Coder
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
could you put a select box with the continents first? europe, americas... so lazy poeple like me dont have such a big list to scroll through when it gets to the countries...
__________________
redhead
02-23-2003, 12:40 AM
PM User |
#10
Regular Coder
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
I'll look into it.
03-17-2003, 08:57 PM
PM User |
#11
Regular Coder
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally posted by redhead
could you put a select box with the continents first? europe, americas... so lazy poeple like me dont have such a big list to scroll through when it gets to the countries...
Got it:
http://www.angelfire.com/mo2/cbch21/...tySelect2.html
03-18-2003, 08:49 AM
PM User |
#12
Regular Coder
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
heh heh heh! that looks fantastic... nice one...
__________________
redhead
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 09:37 PM .
Advertisement
Log in to turn off these ads.