SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast joejoe04's Avatar
    Join Date
    Mar 2006
    Location
    Akron, OH
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using <select> with Javascript

    Hi,

    I want to use the <select> tag along with the <optgroup> and <option> tags to link to another page when a particular <option> is selected by the visitor. Is there a way to do this besides using javascript or is that required? Thanks.

  2. #2
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since a link tag is not allowed either in or around an option tag, it's hard to imagine any other way to do it client side. On the other hand, a form could call a script at the server that would forward the client to another page.

    Alternatively, it should be possible, using CSS, to get a list to simulate a select, and links can exist within a list. It still might require JavaScript, depending on how closely you need to mimic the function of a select.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You can do it server side instead by having a form containing the select and a submit button. Your visitor selectas the entry from the select and presses the submit button. This then calls the action from the form which is a server side script to take the value passed from the select and tthen transfer to the required page. See http://javascript.about.com/od/dropd...Navigation.htm for a series of tutorials showing this and other alternatives and how to combine them.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Enthusiast joejoe04's Avatar
    Join Date
    Mar 2006
    Location
    Akron, OH
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the responses. Yeah, I did one using CSS on the homepage of a site thats not done yet... http://www.usedsemitires.com. Seems to me like there should be an attribute for this, but I will definitely take a look at your suggestions. Thanks again.


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
  •