jennypretty
IS-IT--Management
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!
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!