SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Select Form

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    USA
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select Form

    I have a form. And nide the form I have a select dropdown box. For example...
    <form action="default.asp" method="post">
    <select name="groups">
    <option>Email Group One
    <option>Email Group Two
    </select>
    </form>

    I can use a onChange on the <select> part to make it activate a JS function. But When I use onClick on the <option> part it doesn't do anything. I could use onChange on the <select> part but I want each dropdown part to go to a different page. Like Email Group One, goes to page1.asp, and email Group Two, goes to page2.asp. Anybody know how to do this?
    Chad Crouch
    http://chadmc.com

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Chad,

    <head>
    <script>
    actionStr = "";
    function doSel(selObj)
    {
    for (i=0; i < selObj.length; i++)
    if (selObj.options[i].selected)
    actionStr = selObj.options[i].value;
    }
    ....either in the function above or somewhere else...
    ....code....
    myForm.action = actionStr;
    myForm.submit();

    </script>
    <body>
    <form name='myForm'>
    <select name='mySel' onChange='doSel(this)'>
    <option value='page1.asp'>Group one</option>
    <option value='page2.asp'>Group Two</option>
    </select>
    </form>

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •