How to redirect to different page by if condition using asp?

hello, I have asp page contain a form for making choice by selecting from radio button list.

And example like

pizza

  1. big 2. small 3.medium

submit

proceed

I would like that depends on which choice the user made, the proceed button direct to different page.

if user chose 1 , after proceed button, redirect to big.asp
if … 2, after proceed button, redirect to small.asp

I would like to know how to write the code for this if condition with the proceed button. Is it possible?

Thanks very much in advance and wait for your reply!

if choice = "1"
then response.redirect "big.asp"
end if

if choice = "2"
then response.redirect "small.asp"
end if

or you could use select case statements…

www.asp101.com/samples

^ if you are at this level in asp, go to that link, it will teach you all the basics…

but how about I have button for proceed and it can only go forward to the next page when the proceed button is pressed. How should I add that funtion to the button then?

the button should contain a link to the next page containing the variable…for example:
have your main index…
index.htm contain a form with the radio buttons and a “proceed” or “submit” button:

the radio button would be assigned variable name “choice”

all of them having the same name, each with a different value…

like under their properties:

Button#1
name: Choice
value: 1

Button#2
name:Choice
value: 2

You would set up your form to use the “post” method. Then you would have it link to say for example:“http://www.choices.com/choice.asp

When that proceed button is pressed, it sends the variable from the radio buttons automatically to the “choice.asp” file.

The choice.asp file contains all of the processing “if then” statements.

So in this fashion, you have a start page that contains a form with radio buttons and a proceed button.

Each radio button has the same “name” but a different “value.”

The form is using the post command to point to the processing page.

The processing page contains all of the processing rules(the if then stuff)

Let me know if you need anything else!

:slight_smile:
So you don’t have to assign a “function” to it. Just make sure that its link contains the variable information

Here is a great tutorial on what I just talked about with pictures.

http://www.htmlgoodies.com/ASP/ASP_p7a.html

***edit its for ASP email processing…but the first page’s form setup is roughly the same idea, and it shows the different types of input involved…

for illustrative purposes ha

Thanks very much for your help.I have other variables must be sent while redirection. Then how should I write the code for


<%
if(choice="1" then 
response.redirect  "small.asp?......" -----how should I write here to send my variables at the same time while redirection

Thanks again!

<% if choice=“1” then
response.redirect "small.asp?findby=1+variable=2+another=3"
end if
%>

hello, thanks very much for your help and now it is done. Thanks for the link also. It is quite helpful!

Have a nice weekend!:slight_smile:

Glad I could help out. More glad that you have it working!!!

Hope you have a great weekend as well!

If you need anything more, don’t hesitate to ask!