Click to See Complete Forum and Search --> : Change form redirect location from dropdown.


Chris Jacks
11-11-2003, 10:35 PM
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

Khalid Ali
11-12-2003, 06:22 AM
looks like you want something like this


http://www.webapplikations.com/pages/html_js/forms/DropDownOpenSelectedLink.html

Chris Jacks
11-12-2003, 04:27 PM
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.

bizx
04-03-2006, 09:33 AM
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?

phpnovice
04-03-2006, 10:42 AM
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.

bizx
04-03-2006, 11:39 AM
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.

phpnovice
04-03-2006, 11:50 AM
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 (http://www.webreference.com/programming/javascript/diaries/). When you complete it, then we can talk.