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 biv343 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 submit button interaction - URGENT!! 1

Status
Not open for further replies.

croag

MIS
Nov 8, 2001
49
US
Hello,

Here are the facts...

1.) I've got 1 column from a bunch records being returned from an oracle DB and automatically through a loop, the values are having radio buttons put right next to them.

2.) There is a submit button below all of the values (with corresponding radio buttons) that get returned.


This is what I need...


--- What I need to know how to do is click on an option button to select which 1 of the records I want and then click the submit button and have that 1 value that was selected be passed to the next page and have the 1 value be avalible to the next page so that I can do a search off my Database and return the WHOLE record from that 1 value from the prior page.


I searched all around and I don't know how to do this , ESPECIALLY the Radio buttons.

Thanks very very very much for any help,

T.J.
 
In your initial loop, create the radio buttons, all with the same name, and set the values to the id/value of the record as such:


<input type=&quot;radio&quot; name=&quot;record&quot; value=&quot;<%=rs(&quot;id&quot;)%>&quot;>

(obviously substitute the values for the relevant ones to you)

Then, on your next page, simply check the value of the 'record' field from the form i.e.

selectedRecord = Request.Form(&quot;record&quot;)

Then just perform your database query with this value as such:

strSQL = &quot;SELECT * FROM database WHERE id=&quot; & selectedRecord

Will return all the details of that one record.

Hope this helps, if you need clarification just ask ;)



Nick (Software Developer)


nick@retrographics.fsnet.co.uk
nick.price@myenable.com
 
Thanks for your help!! Let me Clarify a couple of things from your response.....


In your initial loop, create the radio buttons, all with the same name, and set the values to the id/value of the record as such:

<input type=&quot;radio&quot; name=&quot;record&quot; value=&quot;<%=rs(&quot;id&quot;)%>&quot;>



This was really helpfull, THANKS!!


Then, on your next page, simply check the value of the 'record' field from the form i.e.

selectedRecord = Request.Form(&quot;record&quot;)




This is the part where I think there might be some misunderstanding. You say on the next page, but What I was looking for is the radio buttons to be returned from Hyperlinks, ie A, B, C, D, E, F..... and When they click on one of those hyper links, that's when the radio buttons are generated..on that same page. But I 've already got that part to work. I just need to know how the submit button below all of the radio buttons can submit just 1 of the radio button values.


Then just perform your database query with this value as such:

strSQL = &quot;SELECT * FROM database WHERE id=&quot; & selectedRecord

Will return all the details of that one record.



This is the part that is going to be carried on to the next page where all the details for that 1 value from the previous page are going to be returned.

Let me give you a link to what I've done so far so you can get a better Idea what I'm looking for..



Thanks a million for all your help!!!!


T.J.
 
For some reason I couldn't open that asp file properly... seemed a bit corrupted. But I did manage to glean something from it:

I think your problem lies in your understanding of the way radio buttons work. You have correctly named all of the radio buttons with the same name, but the values are also all the same. You need to set the value to an id which uniquely identifies the record it represents. So your code should go something like this:

Do Until objRS.EOF
%>
<tr>
<td>
<input type=&quot;radio&quot; name=&quot;record&quot; value=&quot;<%=objRS(&quot;COM_NAME&quot;)%>&quot;>
</td>
<td>
<%=objRS(&quot;COM_NAME&quot;)%>
</td>
</tr>
<%
Loop
%>

When you press submit, the value of the selected radio button (and that value only) will be passed to the next page. You can access it via Request.Form(&quot;record&quot;)

So:

If the user pressed the radio button with the value 'C',
Request.Form(&quot;record&quot;) would return 'C' as the value.

So you can then go on to access the other details of that record on the next page by using the received variable in your select statement:

strSQL = &quot;SELECT * FROM COM_COMPANY WHERE COM_NAME ='&quot; & Request.Form(&quot;record&quot;) & &quot;'&quot;

Does this help at all or have i misunderstood?
Nick (Software Developer)


nick@retrographics.fsnet.co.uk
nick.price@myenable.com
 
Thanks you so very much. You have helped me beyond what I can even tell you.!!

Thanks again,

T.J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top