Results 1 to 8 of 8

Thread: How would you code this...??

  1. #1
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How would you code this...??

    I am trying to establish a way for site visitors to be able to select what they want and as they click on 'go', it takes them there...

    so far, I have learned the single-selection code, and would like to expend to something that provides multiple-selection code.

    example of what I am speaking about....

    "Where do you live?" - Here the visitiors click on "state" then select "county" then select "city".... after their selections have been made, they click on 'go', then it takes them to their town, on the site!

    So, if you can help, please do!

    Greatly appreciated!

    JL

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    HTML Code:
    <select id="state">
    <option value="mi">Michigan</option>
    <option value="ca">California</option><!-- Californya, Californyaaa... woooaah, Californya... -->
    </state>
    
    <select id="county">
    <!-- I don't know any American counties. -->
    <option value="hearts">Heartfordshire</option>
    <option value="wsus">West Sussex</option>
    </select>
    
    <select id="city">
    <option value="ny">New York</option>
    <option value="la">Los Angeles</option>
    </select>
    
    <button onclick="window.location.href='/' + document.getElementById('state').value + '/' + document.getElementById('county').value + '/' + document.getElementById('city').value + '.htm';">Go!</button>
    For example, if the user selected "Michigan," "Heartfordshire," and "New York," this would take them to http://www.yoursite.com/mi/hearts/ny.htm.

    Sorry my American geography's a bit whacked, I'm English and it was never my best subject anyway
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    HTML Code:
    <select id="state">
    <option value="mi">Michigan</option>
    <option value="ca">California</option><!-- Californya, Californyaaa... woooaah, Californya... -->
    </state>
    
    <select id="county">
    <!-- I don't know any American counties. -->
    <option value="hearts">Heartfordshire</option>
    <option value="wsus">West Sussex</option>
    </select>
    
    <select id="city">
    <option value="ny">New York</option>
    <option value="la">Los Angeles</option>
    </select>
    
    <button onclick="window.location.href='/' + document.getElementById('state').value + '/' + document.getElementById('county').value + '/' + document.getElementById('city').value + '.htm';">Go!</button>
    For example, if the user selected "Michigan," "Heartfordshire," and "New York," this would take them to http://www.yoursite.com/mi/hearts/ny.htm.

    Sorry my American geography's a bit whacked, I'm English and it was never my best subject anyway
    towards the end of the code, you have specified '.htm'.... For this, do I have to type the URL to complete the coding?

    thanks!

    JL

  4. #4
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default never mind the last question...

    I read thru it, and answered my own question!

    Thank you though for your great help!

    ps. you'd said that English is not your best subject (or something like that), but HTML is definitely something of your better interest!

    JL

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Nonono, "Geography" was the last noun, hence referred to by the pronoun "it." "English" was used as an adjective. My English is fine; it's my geography that suffers
    And I'm not nearly as good at HTML as, say, Mike
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default okay... next question regarding this...

    thank you for helping thus far....

    how would you code it if i'd like to display in the 'option box' state, prior to one clicking and selecting the city/state???

    in other words, i would like it to appear 'select state' in the box, then as one clicks on the down arrow, the valid states will appear for selection.

    please help!

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ooh - I just spotted a typo.
    Quote Originally Posted by Me
    <select id="state">
    <option value="mi">Michigan</option>
    <option value="ca">California</option><!-- Californya, Californyaaa... woooaah, Californya... -->
    </state>
    It should be </select>, not </state>. Surprised no-one picked up on that!

    HTML Code:
    <script type="text/javascript">
    function go() {
    var s = document.getElementById('state').value;
    var c = document.getElementById('county').value;
    var i = document.getElementById('city').value;
    if ((s === "NONE") || (c === "NONE") || (i === "NONE")) return false;
    window.location.href='/' + s + '/' + c + '/' + i + '.htm';
    return true;
    }
    </script>
    
    <select id="state">
      <option value="NONE">Select State...</option>
      <option value="mi">Michigan</option>
      <option value="ca">California</option>
    </select>
    <select id="county">
    <!-- I don't know any American counties. -->
      <option value="NONE">Select County...</option>
      <option value="hearts">Heartfordshire</option>
      <option value="wsus">West Sussex</option>
    </select>
    <select id="city">
      <option value="NONE">Select City...</option>
      <option value="ny">New York</option>
      <option value="la">Los Angeles</option>
    </select>
    <button onclick="go();">Go!</button>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am guessing this coding is going to appear like I asked... I will try it... thanks!

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
  •