I'm trying to figure out what does not happen here. I insert some data in "AddNew", the text values but not the radio button information are then returned in a page labelled "Edit" after passing through "Insert".
When I fill in the radio button info on "Edit", the data then shows up in "View" correctly. The problem is that I have to enter the radio button data more than once and should not have to.
How can I get the correctly checked Radio Button value to show up in Edit?
The relevant parts of the code follow:
ADDNEW (1)
Response.Write "<form action='Reporting.asp?op=Insert&ReportID=" & ReportID & "' method='post'>"
Response.Write "<table>"
do until rst.EOF
Response.Write "<tr>"
Response.Write "<th align='left'>" & rst("Question" & "</th>"
Response.Write "<input type='hidden' name='QuestionID' value='" & rst("QuestionID" & "'>"
If rst("DataTypeID" = 4 then
Response.Write "<td>"
Response.Write "<INPUT type='radio' name= 'Answer" & trim(rst("QuestionID") & "CHECKED Value = 'Yes'>" & " Yes "
Response.Write "<INPUT type='radio' name= 'Answer" & trim(rst("QuestionID") & "Value = 'No'>" & " No"
Response.Write "</td>"
Else
Response.Write "<td>" & "<input type='text' name='Answer" & trim(rst("QuestionID") & "'>" & "</td>"
End if
Response.Write "</tr>"
rst.MoveNext
loop
Response.Write "<tr><td colspan='2'><input type='submit' name='sent' value='Submit'></td></tr>"
Response.Write "</table>"
Response.Write "</form>"
INSERT (2)
Questions=split(Request.Form("QuestionID",","
strSQL="SELECT * FROM tblReportData WHERE 1=0"
rst.open strSQL, cxn, 1, 3 'adOpenKeyset, adLockOptimistic
rst.AddNew
rst("UserID"=Request.Cookies("UserID"
rst("DateCreated"=Now()
rst("ReportID"=ReportID
rst.Update
ReportDataID=rst("ReportDataID".Value
rst.Close
for i=lbound(Questions) to ubound(Questions)
Value=trim(Request.Form("Answer" & trim(Questions(i))))
Value=replace(Value,"$", ""
Value=replace(Value,",",""
strSQL="INSERT INTO tblQuestionData(QuestionID, ReportDataID, Value)"
strSQL=strSQL & "VALUES(" & trim(Questions(i)) & ", " & ReportDataID & ", "
strSQL=strSQL & "'" & Value & "')"
cxn.Execute strSQL
next
Response.Redirect("Reporting.asp?op=Edit&ReportDataID=" & ReportDataID)
EDIT (3)
ReportDataID=trim(Request.QueryString("ReportDataID")
strSQL="SELECT tblQuestions.QuestionID, tblQuestions.Question, " & _
"tblQuestionData.QuestionDataID, tblQuestions.DataTypeID, " & _
"tblQuestionData.Value " & _
"FROM tblQuestions, tblQuestionData " & _
"WHERE tblQuestionData.QuestionID *= tblQuestions.QuestionID AND " & _
"tblQuestions.active = 1 " & _
"AND tblQuestionData.ReportDataID = " & ReportDataID
rst.Open strSQL, cxn
Response.Write "<form action='Reporting.asp?op=Update' method='post'>"
Response.Write "<input type='hidden' name='reportDataID' value='" & ReportDataID & "'>"
Response.Write "<table>"
do until rst.EOF
Response.Write "<tr>"
Response.Write "<th align='left'>" & rst("Question" & "</th>"
Response.Write "<td align='left'>"
QID=trim(rst("QuestionID")
Response.Write "<input type='hidden' name='QuestionDataID' value='" & rst("QuestionDataID" & "'>"
Response.Write "<input type='hidden' name='QuestionID' value='" & QID & "'>"
Value=FormatData(rst("Value",rst("DataTypeID")
'from formatfunctions.asp
If rst("DataTypeID" = 4 then
Response.Write "<INPUT type='radio' name='QuestionData" & QID & "' value='Yes'>" & " Yes "
Response.Write "<INPUT type='radio' name='QuestionData" & QID & "' value='No'>" & " No "
Else
Response.Write "<input type='text' name='QuestionData" & QID & "' value='" & Value & "'>"
End if
Response.Write "</td>"
Response.Write "</tr>"
rst.MoveNext
loop
Response.Write "<tr><td colspan='2' align='center'><input type='submit' name='sent' value='Update Report'></td></tr>"
Response.Write "</table>"
Response.Write "</form>"
rst.Close
UPDATE (4)
ReportDataID=trim(Request.Form("ReportDataID")
if trim(Request.Form("sent")<>"" then
QuestionDataID=split(Request.Form("QuestionDataID",","
QuestionID=split(Request.Form("QuestionID",","
for i=lbound(QuestionID) to ubound(QuestionID)
if ubound(QuestionDataID)>=i then
QDID=trim(QuestionDataID(i))
end if
QID=trim(QuestionID(i))
Value=trim(Request.Form("QuestionData" & QID))
Value=replace(value,",",""
if QDID<>"" then
strSQL="UPDATE tblQuestionData SET Value='" & Value & "' " & _
"WHERE QuestionDataID=" & QDID
else 'insert new record
strSQL="INSERT INTO tblQuestionData(QuestionID, ReportDataID, Value) " & _
"VALUES(" & trim(QuestionID(i)) & ", " & ReportDataID & ", '" & Value & "')"
end if
cxn.Execute strSQL
next
end if
Response.Redirect("Reporting.asp?op=View&ReportDataID=" & ReportDataID)
VIEW (5)
strSQL="SELECT tblQuestions.QuestionID, tblQuestions.Question, " & _
"tblQuestionData.QuestionDataID, tblQuestions.DataTypeID, " & _
"tblQuestionData.Value " & _
"FROM tblQuestions, tblQuestionData " & _
"WHERE tblQuestionData.QuestionID *= tblQuestions.QuestionID AND " & _
"tblQuestions.active = 1 " & _
"AND tblQuestionData.ReportDataID = " & ReportDataID
rst.Open strSQL, cxn
do until rst.EOF
Response.Write "<tr>"
Response.Write "<th align='left'>" & rst("Question" & "</th>"
Value=FormatData(rst("Value",rst("DataTypeID")
Response.Write "<td>" & Value & "</td>"
Response.Write "</tr>"
rst.MoveNext
loop
Response.Write "</table>"
rst.Close
When I fill in the radio button info on "Edit", the data then shows up in "View" correctly. The problem is that I have to enter the radio button data more than once and should not have to.
How can I get the correctly checked Radio Button value to show up in Edit?
The relevant parts of the code follow:
ADDNEW (1)
Response.Write "<form action='Reporting.asp?op=Insert&ReportID=" & ReportID & "' method='post'>"
Response.Write "<table>"
do until rst.EOF
Response.Write "<tr>"
Response.Write "<th align='left'>" & rst("Question" & "</th>"
Response.Write "<input type='hidden' name='QuestionID' value='" & rst("QuestionID" & "'>"
If rst("DataTypeID" = 4 then
Response.Write "<td>"
Response.Write "<INPUT type='radio' name= 'Answer" & trim(rst("QuestionID") & "CHECKED Value = 'Yes'>" & " Yes "
Response.Write "<INPUT type='radio' name= 'Answer" & trim(rst("QuestionID") & "Value = 'No'>" & " No"
Response.Write "</td>"
Else
Response.Write "<td>" & "<input type='text' name='Answer" & trim(rst("QuestionID") & "'>" & "</td>"
End if
Response.Write "</tr>"
rst.MoveNext
loop
Response.Write "<tr><td colspan='2'><input type='submit' name='sent' value='Submit'></td></tr>"
Response.Write "</table>"
Response.Write "</form>"
INSERT (2)
Questions=split(Request.Form("QuestionID",","
strSQL="SELECT * FROM tblReportData WHERE 1=0"
rst.open strSQL, cxn, 1, 3 'adOpenKeyset, adLockOptimistic
rst.AddNew
rst("UserID"=Request.Cookies("UserID"
rst("DateCreated"=Now()
rst("ReportID"=ReportID
rst.Update
ReportDataID=rst("ReportDataID".Value
rst.Close
for i=lbound(Questions) to ubound(Questions)
Value=trim(Request.Form("Answer" & trim(Questions(i))))
Value=replace(Value,"$", ""
Value=replace(Value,",",""
strSQL="INSERT INTO tblQuestionData(QuestionID, ReportDataID, Value)"
strSQL=strSQL & "VALUES(" & trim(Questions(i)) & ", " & ReportDataID & ", "
strSQL=strSQL & "'" & Value & "')"
cxn.Execute strSQL
next
Response.Redirect("Reporting.asp?op=Edit&ReportDataID=" & ReportDataID)
EDIT (3)
ReportDataID=trim(Request.QueryString("ReportDataID")
strSQL="SELECT tblQuestions.QuestionID, tblQuestions.Question, " & _
"tblQuestionData.QuestionDataID, tblQuestions.DataTypeID, " & _
"tblQuestionData.Value " & _
"FROM tblQuestions, tblQuestionData " & _
"WHERE tblQuestionData.QuestionID *= tblQuestions.QuestionID AND " & _
"tblQuestions.active = 1 " & _
"AND tblQuestionData.ReportDataID = " & ReportDataID
rst.Open strSQL, cxn
Response.Write "<form action='Reporting.asp?op=Update' method='post'>"
Response.Write "<input type='hidden' name='reportDataID' value='" & ReportDataID & "'>"
Response.Write "<table>"
do until rst.EOF
Response.Write "<tr>"
Response.Write "<th align='left'>" & rst("Question" & "</th>"
Response.Write "<td align='left'>"
QID=trim(rst("QuestionID")
Response.Write "<input type='hidden' name='QuestionDataID' value='" & rst("QuestionDataID" & "'>"
Response.Write "<input type='hidden' name='QuestionID' value='" & QID & "'>"
Value=FormatData(rst("Value",rst("DataTypeID")
'from formatfunctions.asp
If rst("DataTypeID" = 4 then
Response.Write "<INPUT type='radio' name='QuestionData" & QID & "' value='Yes'>" & " Yes "
Response.Write "<INPUT type='radio' name='QuestionData" & QID & "' value='No'>" & " No "
Else
Response.Write "<input type='text' name='QuestionData" & QID & "' value='" & Value & "'>"
End if
Response.Write "</td>"
Response.Write "</tr>"
rst.MoveNext
loop
Response.Write "<tr><td colspan='2' align='center'><input type='submit' name='sent' value='Update Report'></td></tr>"
Response.Write "</table>"
Response.Write "</form>"
rst.Close
UPDATE (4)
ReportDataID=trim(Request.Form("ReportDataID")
if trim(Request.Form("sent")<>"" then
QuestionDataID=split(Request.Form("QuestionDataID",","
QuestionID=split(Request.Form("QuestionID",","
for i=lbound(QuestionID) to ubound(QuestionID)
if ubound(QuestionDataID)>=i then
QDID=trim(QuestionDataID(i))
end if
QID=trim(QuestionID(i))
Value=trim(Request.Form("QuestionData" & QID))
Value=replace(value,",",""
if QDID<>"" then
strSQL="UPDATE tblQuestionData SET Value='" & Value & "' " & _
"WHERE QuestionDataID=" & QDID
else 'insert new record
strSQL="INSERT INTO tblQuestionData(QuestionID, ReportDataID, Value) " & _
"VALUES(" & trim(QuestionID(i)) & ", " & ReportDataID & ", '" & Value & "')"
end if
cxn.Execute strSQL
next
end if
Response.Redirect("Reporting.asp?op=View&ReportDataID=" & ReportDataID)
VIEW (5)
strSQL="SELECT tblQuestions.QuestionID, tblQuestions.Question, " & _
"tblQuestionData.QuestionDataID, tblQuestions.DataTypeID, " & _
"tblQuestionData.Value " & _
"FROM tblQuestions, tblQuestionData " & _
"WHERE tblQuestionData.QuestionID *= tblQuestions.QuestionID AND " & _
"tblQuestions.active = 1 " & _
"AND tblQuestionData.ReportDataID = " & ReportDataID
rst.Open strSQL, cxn
do until rst.EOF
Response.Write "<tr>"
Response.Write "<th align='left'>" & rst("Question" & "</th>"
Value=FormatData(rst("Value",rst("DataTypeID")
Response.Write "<td>" & Value & "</td>"
Response.Write "</tr>"
rst.MoveNext
loop
Response.Write "</table>"
rst.Close