Results 1 to 4 of 4

Thread: City Chooser Drop Down?

  1. #1
    Join Date
    Nov 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default City Chooser Drop Down?

    I would like a script that would be a drop down almost like a state picker. So it will say "what city" you click and find the one you want and on click you are directed to the page about that city. Any ideas? Thanks!

  2. #2
    Join Date
    Jan 2009
    Location
    NH
    Posts
    631
    Thanks
    96
    Thanked 24 Times in 24 Posts

    Default

    Last edited by mlegg; 11-25-2013 at 11:44 PM.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Are you having trouble with the code? Or with the list of cities? Those are two separate problems.
    For the first, something like mlegg posted would work, or any normal state dropdown.
    For the second, that's not really a problem we can answer here (although you can search for an existing script on the internet to see if anyone came up with a list). Specifically, the problem is that you would need to choose a certain region-- listing all cities (in the world? in the country?) would be far too much.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,734
    Thanks
    46
    Thanked 216 Times in 209 Posts
    Blog Entries
    53

    Default

    Something like this?
    <head>
    <script>
    //This script enables execution of scripts by putting them in the options of selectboxes (if the text of a given option corresponds with the contents of a given script, then the script is executed when the option is clicked on).
    function load_script_container()
    {var div_node=document.createElement('div');
    div_node.setAttribute("id", "script_container");
    document.body.appendChild(div_node);}
    //window.onload=load_script_container

    function javascript_in_selectbox(which_box) {
    var optionValue=document.getElementById(which_box).options[document.getElementById(which_box).selectedIndex].value;
    if (optionValue=="none") {}
    else {
    var script_inside_selectbox_option = document.createElement('script');
    script_inside_selectbox_option.type = 'text/javascript';
    script_inside_selectbox_option.text = optionValue;
    while(document.getElementById("script_container").firstChild)
    {document.getElementById("script_container").removeChild(document.getElementById("script_container").firstChild);}
    document.getElementById("script_container").appendChild(script_inside_selectbox_option);
    }
    }

    if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", load_script_container, false );
    else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onload", load_script_container );
    else {
    if ( window.onload != null ) {
    var oldOnload = window.onload;
    window.onload = function ( e ) {
    oldOnload( e );
    load_script_container();
    };
    }
    else
    window.onload = load_script_container;
    }
    </script>
    </head>

    <body>
    <select id="choose_city" onchange="javascript_in_selectbox('choose_city'); selectedIndex=0" onfocus="selectedIndex=0" style="font-family: verdana; font-size: 11px; cursor: pointer; width:100px" >
    <option value="none" selected >Choose city</option>
    <optgroup label="&nbsp;United States" style="font-family:verdana;">
    <option value="frames.cities.location.replace('http://www1.nyc.gov')">New York</option>
    <option value="frames.cities.location.replace('http://www.sfgov.org/index.asp')">San Francisco</option>
    </optgroup>
    <option disabled>&nbsp;</option>
    <optgroup label="&nbsp;The Netherlands" style="font-family:verdana;">
    <option value="frames.cities.location.replace('http://nl.wikipedia.org/wiki/Amsterdam')">Amsterdam</option>
    <option value="frames.cities.location.replace('http://www.nrc.nl/nieuws/2013/11/26/aardbevingen-groningen-mogelijk-nog-krachtiger/')">Groningen</option>
    </optgroup>
    </select> &nbsp;<span style="cursor: pointer" onclick="window.location.reload()">reset</span>

    <div style="position: absolute; left: 10%; top: 10%; right: 10%; bottom: 10%; border: 0px">
    <iframe name="cities" src="about:blank" frameborder="0" style="position: absolute; width: 100%; height: 100%"></iframe>
    </div>

    <script>
    frames.cities.location='about:blank'
    </script>
    </body>

Similar Threads

  1. Html state/city drop down menu
    By rayro in forum Looking for such a script or service
    Replies: 0
    Last Post: 08-28-2008, 05:05 PM
  2. Font Chooser window
    By rahulrborkar in forum JavaScript
    Replies: 3
    Last Post: 05-15-2008, 11:59 PM
  3. Thumbnail image chooser - please help!!!
    By ljh80 in forum JavaScript
    Replies: 3
    Last Post: 07-17-2007, 05:43 PM
  4. gta liberty city for psp
    By Demonicman in forum The lounge
    Replies: 15
    Last Post: 02-28-2007, 06:20 AM
  5. Custom product chooser
    By MrH2o in forum ASP
    Replies: 0
    Last Post: 03-20-2006, 09:58 AM

Bookmarks

Posting Permissions

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