Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button and Onclick redirect 1

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Hi,

I have two radio buttons in a form and the outcome for each when clicked is different. I would like the user to make a selection, click submit, and it automatically goes straight to the correct page depending on which item they chose. If they click "credit card" I would like the user redirected to ccinfo.asp, etc. Is this possible and still be able keep it as a form to pass variables?

<form>
<input type=hidden name=&quot;fees&quot; value=&quot;<%=request(&quot;fees&quot;)%>&quot;>
<input type=radio name=&quot;payment&quot; value=&quot;cc&quot;>Credit Card
<input type=radio name=&quot;payment&quot; value=&quot;contact&quot;>Contact me
<input type=submit value=Submit>&nbsp;<input type=reset value=Clear>
</form>

Any help would be greatly appreciated. Thanks.
 
sounds simple...just

if payment =&quot;cc&quot; then
response.redirect &quot;ccinfo.asp&quot;
else
response.redirect &quot;contact.asp&quot;
end if


if you've got other variables that are being sent as well(name, address etc) just request them in like:

name=request(&quot;name&quot;)

etc.

hth
mark
 
It does sound simple, but where do I put that?
 
depends on how you've built the page(s). if the form is submitting to itself, you can just add to the bottom of the page....(make sure you have response.buffer=true at the top of the page that does the redirect!!!). otherwise, you might have a &quot;processor&quot; page where you request everything in and then redirect from there.

mark
 
I spoke too soon. It keeps defaulting to the &quot;contact.asp&quot; no matter which radio button I click.

I don't think I have the syntax right. Is this a function, a sub? How am I supposed to be calling it? Thanks.
 
Take a look at these two test pages: one has a form; second - handles redirection.

radio.htm


<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY>

<form name=&quot;radio&quot; action=&quot;redir.asp&quot; method=&quot;post&quot;>
<input type=&quot;radio&quot; name=&quot;test&quot; value=&quot;check.asp&quot; checked>
<input type=&quot;radio&quot; name=&quot;test&quot; value=&quot;form.asp&quot;>
<input type=&quot;submit&quot;>
</form>

</BODY>
</HTML>


redir.asp


<%@ Language=VBScript %>
<%Response.Buffer=true%>
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>

<%
if request(&quot;test&quot;)= &quot;check.asp&quot; then
Response.Redirect &quot;check.asp&quot;
else
Response.Redirect &quot;form.asp&quot;
end if
%>

</BODY>
</HTML>


Of course, you can use any values you want for radio buttons and check for them in your redirection page, and you'll need to adjust everything according to your needs.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top