SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict will_'s Avatar
    Join Date
    Apr 2004
    Location
    Asheville, NC
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jump to anchor on another page based on selection

    I have a dropdown form selection containing a list of counties:
    Code:
    <form method="POST" name="form1" action="page2.php">
    <select size="1" name="county" onChange="form1.submit()">
    <option value="" selected>Select Your County</option>                                                        <option value="Alamance">Alamance</option>                                                        <option value="Alexander">Alexander</option>                                                        <option value="Alleghany">Alleghany</option>                                                        <option value="Anson">Anson</option>                                                        <option value="Ashe">Ashe</option>                                                        <option value="Avery">Avery</option>                                                        <option value="Beaufort">Beaufort</option>                                                        <option value="Bertie">Bertie</option>
    </select>
    </form>
    I'd like it so that when a county is selected, the user is automatically taken to page2.php and taken to a specific anchor on that page.

    How do I go about specifying the anchor to use based on the selection made in the dropdown, then carry that to the next page and jump down the page to that anchor?

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe look here http://www.sitepoint.com/forums/show...ighlight=bosko
    solution is at the end.
    Hope it helps.

  3. #3
    SitePoint Addict will_'s Avatar
    Join Date
    Apr 2004
    Location
    Asheville, NC
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found a simple solution:

    Code:
    <select size="1" name="county" onchange="document.location='page2.php#' + this.value">
    Putting that as the select tag opening allowed me to make the value of each option the name of the anchor I wanted to jump to on the following page, and all worked well!.

    But thanks for your input!


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
  •