INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Select unique values from radio button

Select unique values from radio button

(OP)
Hello friends:

I tried to create a radio button to get its unique value for each question in SubCat table and store these values in a new table.

How do I fix my code to get its unique value for Report table. For example, when I check on the first Radio for South, then I get a value "1" in the DB Report table. If I check on the second Radio for North, then I get a value of "2" in the DB Report table. Currently, I got values for '0' for all fields. The output will be as below:

Here is my new table for Report:
ReportID CategoryID SubcatID Scale
------------------------------------------
1 01 1 1
2 01 2 2

Category table
CategoryID Category
------------
01 cat
02 cat2
03 cat3

Subcat table
SubcatID Subcat Category_id
-------------------------
1 south 01
2 north 01
3 east 02
4 west 02
5 line 03

ASP Code:
If Request.Form("FormSource") = SubmitForm" Then
sReportID = Request.Form("ReportID")
sCategoryID = Request.Form("CategoryID")
sSubcatID = Request.Form("SubcatID")
sScale = Request.Form("Scale")

SQL = "SET NOCOUNT ON;" &_
INSERT INTO Report (ReportID, CategoryID, SubcatID, Scale) VALUES " &_
"('" & SCategoryID & "', '" & SSubcatID & "', '" & SCategoryID & "', '" & SScale & "');" &_
SELECT @@IDENTITY AS ReportID"
Set objRS = objCon.Execute (SQL)
sReportID = objRS.Fields("ReportID").value
objRS.Close
End If

<form action="" method="post" id="newCategory">
<table>
<tr>
<td>Category and sub</td>
<td>Pass</td>
<td>Fail</td>
<td>NA</td>
</tr>

<%
currCat = ""
sSQL = "SELECT s.*, c.* FROM Category c, Subcat s WHERE s.Subcat_id = c.Subcat_id "
objRS.Open sSQL, objCon
response.Write sSQL
Do Until objRS.EOF
sCategory = objRS("Category")
sSubcat = objRS("Subcat")

if currCat <> sCategory Then
currCat = sCategory
%>
<tr><td><%=sCategory%></td></tr>
<input type="hidden" name="CategoryID" size="40" maxlength="50" value="<%=sCategory%>">
<%
End If
%>
<tr><td><%= sSubcat %></td>
<input type="hidden" name="SubcatID" size="40" maxlength="50" value="<%= sSubcat %>">
<td><input size="20" type="radio" name="<%=sCategory%>" value="1"></td>
<td><input size="20" type="radio" name="<%=sCategory%>" value="2"></td>
<td><input size="20" type="radio" name="<%=sCategory%>" value="3"></td>
</tr>
<%
objRS.MoveNext
Loop

objRS.Close
%>
</table>
<input type="hidden" name="FormSource" value="CatSubmit">
<input type="button" value="Update" onclick="submitForm();">

Thanks so much!

RE: Select unique values from radio button

What does;

Quote:

Currently, I got values for '0' for all fields.

Mean??

And if it actually means

"Currently, I got values for '0' for all fields. after pressing submit"

Which radio button(s) is/are checked??

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Select unique values from radio button

(OP)
Hi Chris,
I checked Radio 1, 2 and 3.
I received all '0' for CategoryID, SubcatID and Scale.
It seems like not capture any values from NOT only radio buttons but hidden INPUT as well.
Thanks.

RE: Select unique values from radio button

HTML forms will pass the values from ALL form elements with the same name attribute as a single comma separated value.

That's how it works, and unchecked radio buttons and checkboxes pass no value

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Select unique values from radio button

(OP)
Chris, how do I fix to pass each unique value for each radio button being checked?
Thanks.

RE: Select unique values from radio button

Append a number to the name attribute is the simplest is simplest HOWEVER that would 'break' the 'radio button' function of only one being selectable.

The correct way is to NOT reuse the radio button name attribute for any other form element UNLESS you are passing a value from earlier form data in a sequence of inputs to be included in the current form data.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close