Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-20-2003, 08:02 PM   PM User | #1
wert
New Coder

 
Join Date: Jun 2002
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
wert is an unknown quantity at this point
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
wert is offline   Reply With Quote
Old 02-20-2003, 08:53 PM   PM User | #2
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
I've got something like that:

Will show the states if USA is picked, but not other countries.
__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·

Last edited by Quiet Storm; 02-20-2003 at 10:49 PM..
Quiet Storm is offline   Reply With Quote
Old 02-20-2003, 10:27 PM   PM User | #3
wert
New Coder

 
Join Date: Jun 2002
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
wert is an unknown quantity at this point
Thanx, but actually I'm looking for the list of states-contries, most of all...

But thanx any way
wert is offline   Reply With Quote
Old 02-20-2003, 10:55 PM   PM User | #4
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
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>
__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·
Quiet Storm is offline   Reply With Quote
Old 02-20-2003, 11:01 PM   PM User | #5
joh6nn
wei wu wei


 
joh6nn's Avatar
 
Join Date: Jun 2002
Location: 72° W. 48' 57" , 41° N. 32' 04"
Posts: 1,887
Thanks: 0
Thanked 1 Time in 1 Post
joh6nn is an unknown quantity at this point
http://www.google.com/search?hl=en&l...=Google+Search
__________________
bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

i am a loser geek, crazy with an evil streak,
yes i do believe there is a violent thing inside of me.
joh6nn is offline   Reply With Quote
Old 02-20-2003, 11:01 PM   PM User | #6
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
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>
__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·
Quiet Storm is offline   Reply With Quote
Old 02-20-2003, 11:11 PM   PM User | #7
wert
New Coder

 
Join Date: Jun 2002
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
wert is an unknown quantity at this point
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
wert is offline   Reply With Quote
Old 02-22-2003, 08:12 PM   PM User | #8
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
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.
__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·
Quiet Storm is offline   Reply With Quote
Old 02-22-2003, 10:11 PM   PM User | #9
redhead
Regular Coder

 
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
redhead is an unknown quantity at this point
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
redhead is offline   Reply With Quote
Old 02-23-2003, 12:40 AM   PM User | #10
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
I'll look into it.

__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·
Quiet Storm is offline   Reply With Quote
Old 03-17-2003, 08:57 PM   PM User | #11
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
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

__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·
Quiet Storm is offline   Reply With Quote
Old 03-18-2003, 08:49 AM   PM User | #12
redhead
Regular Coder

 
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
redhead is an unknown quantity at this point
heh heh heh! that looks fantastic... nice one...
__________________
redhead
redhead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:37 PM.


Advertisement
Log in to turn off these ads.