Results 1 to 5 of 5

Thread: Changing form action with a dropdown

  1. #1
    Join Date
    Nov 2005
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Changing form action with a dropdown

    I have a form, and i would like the user to be able to submit it to different servers by selecting a option from a <select> menu and it would change the value of the action page in <form> without reloading the page

    so i think it would be something like this

    <form action=javascript:action; >

    Thanks in advance!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Something like the below select menu should do it:

    Code:
    <select size="1" onChange="this.form.action=this.options[this.selectedIndex].value;">
    <option value="default.php">Select action</option>
    <option value="bob.php">Bob</option>
    <option value="joe.php">Joe</option>
    </select>

  3. #3
    Join Date
    Nov 2005
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you soooo much, that is exactly what i want! Thanks!!!!!!

  4. #4
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Why doesn't this work?

    I am trying to get the action to submit to a different web page based upon which item they select in the drop down list. Here is what I have:

    <form id="ClassSearch" name="ClassSearch" method="get" action=javascript:action>
    <p>
    <label for="GroupId"><strong>Center:</strong></label>
    <select name="GroupId" id="GroupId" onChange="this.form.action=this.options[this.selectedIndex].value;">
    <option value="http://www.nhconn.com/LOCALWEB/catalog/CourseCatalog.aspx">Bloomfield, CT</option><option value="http://www.nhconn.com/LOCALWEB/catalog/CourseCatalog.aspx">Hartford, CT</option>
    <option value="http://www.nhboston.com/LOCALWEB/catalog/CourseCatalog.aspx">Boston, MA</option>
    <option value="http://www.nhnhboston.com/LOCALWEB/catalog/CourseCatalog.aspx">Waltham, MA</option>
    <option value="http://www.nhnj.com/LOCALWEB/catalog/CourseCatalog.aspx">Iselin, NJ</option>
    <option value="http://www.nhnj.com/LOCALWEB/catalog/CourseCatalog.aspx">Parsippany, NJ</option>
    <option value="http://www.nhnj.com/LOCALWEB/catalog/CourseCatalog.aspx">Princeton, NJ</option>
    <option value="http://www.nhphilly.com/LOCALWEB/catalog/CourseCatalog.aspx">Philadelphia, PA</option>
    <option value="http://www.nhphilly.com/LOCALWEB/catalog/CourseCatalog.aspx">King of Prussia, PA</option> <option value="http://www.nhnashua.com/LOCALWEB/catalog/CourseCatalog.aspx">Nashua, NH</option>
    <option value="http://www.nhny.com/LOCALWEB/catalog/CourseCatalog.aspx">New York, NY</option> <option value="http://www.nhli.com/LOCALWEB/catalog/CourseCatalog.aspx">Long Island, NY</option> <option value="http://www.nhrhodeisland.com/LOCALWEB/catalog/CourseCatalog.aspx">Providence, RI</option> <option value="http://www.nhseattle.com/LOCALWEB/catalog/CourseCatalog.aspx">Seattle, WA</option> </select>
    </p>
    <p>
    <label for="keyword2"><strong>Class:</strong></label>
    <input type="text" name="keyword" id="keyword2" />
    <input name="searchmode" type="hidden" id="searchmode" value="1" />
    </p>
    <p>
    <input type="submit" name="button" id="button" value="Submit" />
    </p>
    </form>

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    It works fine for me! I'm not sure what the issue is. When you select an item, and then press submit, it seems to work fine.
    - Mike

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
  •