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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

radio buttons and asp

Status
Not open for further replies.

georgeous

Programmer
Jul 11, 2001
38
0
0
GB
Hi, I was wondering if anybody could help me.

I have a simple html page which has a form with radio buttons that links to an asp page. When a user a selects a button and clicks submit, I would like to run a piece of sql dependent on the value of the radio button.
can i use if, then and else statements, and if so, how do i lay them out


thanks

 
Can you be more specific?

What kind of SQL statements would you need to run and how does it differ based on radio control values?

[sadeyes] <Dmitriy>
dbrom@crosswinds.net
 
basically, it is a page that searches a database and returns values.
The radio buttons determine what the query searches for,

e.g radio button 1 = would search for items containing the word &quot;fish&quot;

radio button 2 would search for items containing the word &quot;chips&quot;

my sql queries are correct and everything, I just don't know how to call them from the radio buttons.

does this make it clearer?
 
Hoping that you are using method=post for the form.

You can use
if Request.form(&quot;radio1&quot;) = &quot;on&quot; then
sql=
elseif Request.form(&quot;radio2&quot;) = &quot;on&quot; then
sql=
else

end if


Hope this helps.

 
thanks so much for that.
I'll try it tommorrow when I get back into uni.
Thanks again

georgina
 
Try this. This form submits to it self.
and save this as 'caseSelection.asp'
----------------------------------
<html>
<head>
<title>Untitled</title>
</head>

<body>
<form action=&quot;caseSelection.asp&quot; method=&quot;post&quot;>
<input type=&quot;radio&quot; name=&quot;caseSelection&quot; value=&quot;1&quot;> Choice One<br>
<input type=&quot;radio&quot; name=&quot;caseSelection&quot; value=&quot;2&quot;> Choice Two<br>
<input type=&quot;radio&quot; name=&quot;caseSelection&quot; value=&quot;3&quot;> Choice Three<br>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;>
</form>

<%
Dim GotoCaseSelection
GotoSelection = Request.Form(&quot;caseSelection&quot;)

If GotoSelection = &quot;1&quot; Then
Response.Redirect &quot;ElseIf GotoSelection = &quot;2&quot; Then
Response.Redirect &quot;ElseIf GotoSelection = &quot;3&quot; Then
Response.Redirect &quot;test.asp&quot;
Else
Response.Write &quot;wrong selection.&quot;
End If

%>

</body>
</html>
 
georgeous,

Try this, trial.asp

<html>
<head>
<title>Untitled</title>
</head>

<body>
<form action=&quot;trial.asp&quot; method=&quot;post&quot;>
<input type=&quot;radio&quot; name=&quot;test&quot; value=&quot;fish&quot;>Fish<br>
<input type=&quot;radio&quot; name=&quot;test&quot; value=&quot;chips&quot;>Chips<br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>

<%
testing = Request.Form(&quot;test&quot;)

if testing = &quot;fish&quot; then
mySQL = ...
else
if testing = &quot;chips&quot; then
mySQL = ...
end if
end if

(then you can execute your SQL here)

Hope it helps.

Vincent.

%>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top