Results 1 to 2 of 2

Thread: Select a drop-down option via anchor 'name'

  1. #1
    Join Date
    Mar 2006
    Location
    Brew City, WI
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Select a drop-down option via anchor 'name'

    Is there a way to select a 'option' in a drop-down menu by ways of typing in a anchor name in the URL address bar?

    My idea is to have the dropdown menu in with the Dynamic Ajax content and change it's content by what option is selected in the dropdown menu.

    Example: You type in "http://site.com/index.html#tooth" and it will load up the page with 'tooth' as the "SELECTED" option in the dropdown menu and then rely that to the Ajax for what file to select.

    If not are there any other ways of selecting objects when it typed in the url?

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

    Default

    PHP offers a way to do this quite easily.

    Depending on the complexity of your plans, you might have to expand this, but for your simple example above, here's the deal:


    Assume your url is http://.../index.php?selected=tooth (<<note varied syntax, slightly)
    PHP Code:
    <form ...>
    <input type="dropdown" value="<?php //initiates php
    $sel $_GET['selected']; //assigns the 'tooth' (etc) value to the $sel variable.
    echo $sel//prints to html the value of $sel, in this case 'tooth'.
    ?>">
    <more form stuff...>
    </form>
    the above should simplify down to
    PHP Code:
    <form ...>
    <
    input type="dropdown" value="tooth">
    <
    more form stuff...>
    </
    form
    If it needs to be more complex, then get more into php. It can do if statements, loops, and other things that might help you out. Really depends what you need.

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
  •