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!

controlling radio button links

Status
Not open for further replies.

struth

Programmer
Aug 26, 2001
114
GB
Hi

Just starting with ASP and wanted my users to select a radio button then travel to a specific page ... but my code doesn't work..

Any ideas????

TIA

<%
dim amend
cars=Request.Form(&quot;amend&quot;)
%>

<form action=&quot;&quot; name=&quot;form3&quot;>
<p>Which would you like to do:</p>
<input type=&quot;radio&quot; name=&quot;amend&quot;
<%if amend = &quot;update.asp&quot; then Response.Redirect(&quot;checked&quot;)%>
value=&quot;update.asp&quot;>
update<br>
<input type=&quot;radio&quot; name=&quot;amend&quot;
<%if amend = &quot;insertdetails.asp&quot; then Response.Redirect(&quot;checked&quot;)%>
value=&quot;insertdetails.asp&quot;>
Add <br>
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
<%
if amend<>&quot;&quot; then
Response.Redirect( &quot;&amend&&quot; )
end if
%>
 
i think your main problem was that you defined amend, but you then set the value to cars......

<%
dim amend
amend=Request.Form(&quot;amend&quot;)
%>

<form action=&quot;&quot; name=&quot;form3&quot;>
<p>Which would you like to do:</p>
<input type=&quot;radio&quot; name=&quot;amend&quot; value=&quot;update.asp&quot;>
update<br>
<input type=&quot;radio&quot; name=&quot;amend&quot; value=&quot;insertdetails.asp&quot;>
Add <br>
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
<%
if amend<>&quot;&quot; then
Response.Redirect (amend)
end if
%>
 
Er Yup! that I did!? I tried your version but I'm afraid it still reloads the same page rather than travelling to the one allocated to the button. Any ideas

Thanks again
 
simple, simple problem. form method defaults to 'get'. and you didn't specify the method, hence request.form(&quot;amend&quot;) doesn't exist.

I'd change it to (and clean it up along the way..) and I tested this and it worked:

<%
dim amend
amend=Request.Form(&quot;amend&quot;)

if amend<>&quot;&quot; then
Response.Redirect (amend)
end if
%>

<form action=&quot;&quot; name=&quot;form3&quot; method=&quot;post&quot;>
<p>Which would you like to do:</p>
<input type=&quot;radio&quot; name=&quot;amend&quot; value=&quot;update.asp&quot;>
update<br>
<input type=&quot;radio&quot; name=&quot;amend&quot; value=&quot;insertdetails.asp&quot;>
Add <br>
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
 
Ah Right, see what you mean. Clean and it works perfectly. Saved computer and me from the mallet once again. It's the simple things that really get you going.

Really many thanks
Struth
 
This all worked beautifully until I added in another radio button (in a repeated region)then I realised I could have the value from one set of radio buttons or the other but not both. Can you help?

<%
dim amend
amend=Request.Form(&quot;amend&quot;)

if amend<>&quot;&quot; then
Response.Redirect (amend)
end if
%>

<form action=&quot;&quot; name=&quot;form3&quot; method=&quot;post&quot;>
<p>Which would you like to do:</p>
<input type=&quot;radio&quot; name=&quot;amend&quot; value=&quot;update.asp&quot;>
update<br>
<input type=&quot;radio&quot; name=&quot;amend&quot; value=&quot;insertdetails.asp&quot;>
Add <br>
<input type=&quot;radio&quot; name=&quot;DataEntry_ID&quot; value=&quot;<%=(rsActivityDetails.Fields.Item(&quot;DataEntry_ID&quot;).Value)%>&quot;>
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
 
I don't understand your question. Where do you check what's selected for the DataEntry_ID radio button? Is that where your problem is, with that radio button? Could you post more of your code so we could see all that is going on?
 
Discovcered the problem was that my form fields were dropping out as I use dreaweaver's update behaviour but I have solved the problems now thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top