www.webdeveloper.com
Results 1 to 7 of 7

Thread: Change form redirect location from dropdown.

  1. #1
    Join Date
    Feb 2003
    Posts
    102

    Change form redirect location from dropdown.

    I would like to set up some Javascript so that when you make a selection from a dropdown box, it changes the value of my redirect location in the same the form.

    Example:

    Item 1 --> when selected would change the form redirect line to...
    <INPUT type=hidden name="redirect" value="submititem1.htm">

    Item 2 --> when selected would change the form redirect line to...
    <INPUT type=hidden name="redirect" value="submititem2.htm">

    Item 3 --> when selected would change the form redirect line to...
    <INPUT type=hidden name="redirect" value="submititem3.htm">


    Is this possible? Any example code would be much appreciated.
    I have tried fiddling with a simple "goto URL on select" dropdown with no luck!


    Cheers,

    Chris

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,120
    looks like you want something like this


    http://www.webapplikations.com/pages...ectedLink.html
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Feb 2003
    Posts
    102
    Thanks for the reply Khalid. I probably didn't make it clear enough before. I don't actually want a dropdown box that, when you make a selection, takes to to the relevant URL.

    I'm using a perl script to drive my forms named "FormMail" (it's quite popular, you probably know of it). Anyway, my forms start with something like this:

    <form name="myform" METHOD="POST" ACTION="http://www.mywebsite.com.au/cgi-bin/FormMail.pl">
    <INPUT type=hidden name="recipient" value="email1@address.com.au,email2@address.com.au">
    <INPUT type=hidden name="subject" value="form submission">
    <INPUT type=hidden name="redirect" value="submititem1.htm">

    I want the value that is currently "submititem1.htm" to be changed so that when my form is submitted, it will redirect you to a location based upon your selection made earlier in the dropdown box.

  4. #4
    Join Date
    Apr 2006
    Posts
    4
    I too am interested in this answer as I am trying to solve the same problem. the only difference is I am using asp to post the form results and redirect the page.

    Mine begins:
    form action="formmail.asp" method="post" name="form1">
    <input id="mail_to" type="hidden" name="mail_to" value="myemail@domain.com" />
    <input id="mail_redirect" type="hidden" name="mail_redirect" value="submititem1.htm" />
    <input id="mail_send" type="hidden" name="mail_send" value="y" />

    I too want the value that is currently submititem1.htm to be changed so that when my form is submitted, it will redirect you to a location based upon your selection made earlier in the dropdown box.

    Can anyone please help us out?
    Last edited by bizx; 04-03-2006 at 09:36 AM.

  5. #5
    Join Date
    Dec 2004
    Posts
    8,637
    Simple enough -- if the server-side page is not returning any results to the client. If it is, then you're pretty much outta luck. The solution is to use the FORM's onsubmit event to schedule (window.setTimeout) a JavaScript redirect (window.location.href='url') which then takes place *after* the FORM has been submitted to the server.
    Last edited by phpnovice; 04-03-2006 at 10:45 AM.

  6. #6
    Join Date
    Apr 2006
    Posts
    4
    Quote Originally Posted by phpnovice
    Simple enough -- if the server-side page is not returning any results to the client. If it is, then you're pretty much outta luck. The solution is to use the FORM's onsubmit event to schedule (window.setTimeout) a JavaScript redirect (window.location.href='url') which then takes place *after* the FORM has been submitted to the server.
    I appreciate your advice phpnovice, but could you put it in terms for someone just barely getting into javascript? I'm really new at this and don't know what the (window.setTimeout) or (window.location.href='url') is or where to place them.

    I'm a real newbie... Sorry for my ignorance... but I guess that is why I'm here to learn.

  7. #7
    Join Date
    Dec 2004
    Posts
    8,637
    This site is not the place to learn everything you need to know. This is the place to get help with the basics and/or to advance beyond just the basics. This site is not the place to get free contract-programming services. There are no paid nor volunteer helpers (except moderators) at this site to answer questions. Those whom answer questions here are just visitors to this site that happen to enjoy answering a question or two.

    So... Start with a Tutorial. When you complete it, then we can talk.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles