Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #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

  • #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 11:49 PM.
    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!·

  • #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

  • #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>
    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!·

  • #5
    Senior Coder 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
    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.

  • #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>
    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!·

  • #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

  • #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.
    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!·

  • #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

  • #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.

    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!·

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Location
    Beyond Lament
    Posts
    424
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!·

  • #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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •