SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multiple form action??

    hey guys,
    I have a form, which has a <select> with three options.....

    For each option I want to be able to set a different form action........

    eg: if someone selects option 1, the form action goes to url1.html
    or if someone selects option 2, the form goes to url2.html

    How can I achieve this with javascript??

    thanks in advance

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Code:
    <script type='text/javascript'>
    function changeForm(objSelect)
    {
    document.getElementById('form1').action = objSelect[objSelect.selectedIndex].value;
    }
    </script>
     
    <form id='form1' method='post'>
    <select name='select' onChange="changeForm(this)">
    <option value='file1.html'>File 1</option>
    <!-- options here -->
    </select>
    <input type='submit' name='submit' value='Submit' />
    </form>
    Last edited by DJ P@CkMaN; Mar 4, 2003 at 15:11.


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
  •