SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast darkhorse162's Avatar
    Join Date
    Oct 2006
    Location
    Duluth, MN
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop-down no problem. 'go' button not working!

    I want to be able to click on the 'go' button and jump to whatever is currently selected(all internal links).

    Here is my code:
    HTML Code:
    <form name="form1">
       <select name="select2">
          <option selected="selected" value="#top">Top</option>
          <option value="#something1">something1</option>
          <option value="#something2">something2</option>
          <option value="#something3">something3</option>
          <option value="#something4">something4</option>
       </select>
    <input type="button" value="go" onclick="location=document.form1.select2.options[document.form1.select2.selectedindex].value;" />
    </form>
    Nothing happens with the above code.
    I have tried this also:
    HTML Code:
    <form name="form1" onsubmit="location=document.form1.select2.options[document.form1.select2.selectedindex].value;">
       <select name="select2">
           <option selected="selected" value="#top">Top</option>
          <option value="#something1">something1</option>
          <option value="#something2">something2</option>
          <option value="#something3">something3</option>
          <option value="#something4">something4</option>
       </select>
    <input type="button" value="go" />
    </form>
    When I use the onsubmit, it almost works , except it doesn't jump to the internal link, it shows '?select2=%23top' at the end of the url rather than just '#top'.

    Is there any compatibility issues with this between firefox and IE? I believe I have only tested it in firefox.

    Any help please?
    .:::darkhorse162:::.

  2. #2
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does 'location.href' work better than location?

  3. #3
    SitePoint Enthusiast darkhorse162's Avatar
    Join Date
    Oct 2006
    Location
    Duluth, MN
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried location, window.location, and window.location.href. None of which seem to do the trick...
    .:::darkhorse162:::.

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
    <form name="form1">
       <select name="select2">
          <option selected="selected" value="#top">Top</option>
          <option value="#something1">something1</option>
          <option value="#something2">something2</option>
          <option value="#something3">something3</option>
          <option value="#something4">something4</option>
       </select>
    <input type="button" value="go" onclick="window.location=this.form.select2.options[this.form.select2.selectedIndex].value" />
    </form>

  5. #5
    SitePoint Enthusiast darkhorse162's Avatar
    Join Date
    Oct 2006
    Location
    Duluth, MN
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect. Thank you very much Mike.
    .:::darkhorse162:::.


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
  •