View Full Version : go to a different page depending on input in form

08-12-2008, 07:21 AM
I have a form and when it is submitted I would like the action to take the user to two different pages depending on what the input was. Example if the user enters a number less than 10 then to page 1 if between 10 and 19 page 2 and if above 20 page 3 and so on.

Can this be done, I need to be pointed to a tutorial or similar as I am a serious newbie. Is Javascript what I am looking for. I am using PHP.

Also, if not too much to ask, should I also still be able to pass parameters to the next page.

Thanks in Advance

08-12-2008, 07:49 AM
How about posting the data to a single predefined page and execute the code based on the posted data?

Philip M
08-12-2008, 08:01 AM
Here you are:-

<input type = "text" name = "box1" id = "box1" size = "2" maxlength = "2" onblur = "checkit(this)"></br>

<script type = "text/javascript">

function checkit(which) {
x = which.value;
if (!/\d{1,2}/.test(x)) {
alert ("You must enter a one or two-digit number ");
which.value = "";
return false
if (x >= 20) {window.location.href = "page3.html"} // note start with highest number and work down
else if (x >= 10) {window.location.href = "page2.html"}
else {window.location = "page1.html"}


BTW, the time to say "thanks" is afterwards, not beforehand which gives the impression that you take other people's unpaid assistance for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.

08-12-2008, 06:11 PM
Thanks for the etiquette advice. Makes since, I just wanted to express that I would be grateful for any input given, as I know that people take their free/ personal time to write responses. Of course I did not intend to be rude.

Further, thanks for the code advice. I will go work on it right away.


09-12-2008, 09:37 PM
Thanks for the above code.

I can not figure out how to incorporate this into a form. I am looking to pass values from the form into the next web pages based on a calculation from information input into that cell.

Any ideas, please?