SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot charles_i's Avatar
    Join Date
    Apr 2007
    Location
    Toronto, Canada
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I send 2 parameters through onClick from dropdown menu

    Hi guys,

    I have a form with a dropdown menu - onClick sends the user to the page chosen by the option in the dropdown - however I also need to send the choice itself, so I can put it into a database with PHP at the other end. How can I capture the "id" value on click and send it to the next page as well as the next page's URL?

    Code so far works - goes to selected page:
    Code:
     
    <form name="register">
    <select name="solution">
    	<option value="index1.php" id="first option">first option
            <option value="index2.php" id="second option">second option
            <option value="index2.php" id="third option">third option
    </select>
    <input type="button" value="SUBMIT &gt;&gt;" 
    onClick="window.location=document.register.solution.options[document.register.solution.selectedIndex].value">
    </form>
    Thanks
    Charles

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would just make the id of the option its value, POST the form to a form handling PHP, and redirect to index1.php, index2.php etc based on the post variables. No need to really use javascript here.

  3. #3
    SitePoint Zealot charles_i's Avatar
    Join Date
    Apr 2007
    Location
    Toronto, Canada
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that's what I did. Wasn't sure if it was "cheating" to use a redirect page between the pages but had to get it done right away and it worked.

    Thanks again.
    Charles


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
  •