kifeda
11-11-2005, 04:25 PM
Hey All!
I am writing a bit of code that tracks the response of a survey. I use an array to insert multiple records at the same time. I'm trying to do two things: insert the all of the option that user has and then insert a value of one for the option that the user selected- but all on one shot.
The code is below:
What the code does is selected the traits from a recordset called selected traits and then write then with a check box. When the user comes to the page, he/she is supposed to check the traits that apply to him/her and then click the submit button. What it does now is take ALL of the traits and then put them into a table called "Answers" and write the traitid (the unique id for the trait) in the field called (you guessed it) traitid, the author in the author field, and the value in the value field.
Here is the problem:
In the value field, it should write a 1 or a 0 depending if the check box was checked or not. The problem is that if I check the box, the it inserts the 1 or 0 for all of the records instead of for the traits where the user selected them or not. Every insert should be 10 traits for example and for each of those traits, in the value field, it should have a 1 OR a 0 depending on whether or not a user checked the box.
Any help?
Zito
<%
fNumbers = Request.Form("selected")
fAuthor = Request.Form("author")
datecreate = Request.Form("datecreate")
responseid = Request.Form("responseid")
classid = Request.Form("classid")
zito = request.form("trait_id")
Dim mycon, MM_editRedirectUrl
Set mycon = server.createobject("ADODB.Connection")
mycon.ConnectionString = MM_ConnIdeal_STRING
MM_editRedirectUrl = "participant_choose1.asp?response=completed"
mycon.Errors.Clear
mycon.Open
fArray = Split(fNumbers, ",")
For Each i in fArray
strSQL = "INSERT INTO answers (traitid, author, datecreate, responseid, classid, value) VALUES ('" & i & "','" & fAuthor & "','" & datecreate & "','" & responseid & "','" & classid & "','" & zito & "')"
MyCon.execute(StrSQL)
Next
if request.form("submit") <> "" then
Response.Redirect(MM_editRedirectUrl)
end if
%>
I am writing a bit of code that tracks the response of a survey. I use an array to insert multiple records at the same time. I'm trying to do two things: insert the all of the option that user has and then insert a value of one for the option that the user selected- but all on one shot.
The code is below:
What the code does is selected the traits from a recordset called selected traits and then write then with a check box. When the user comes to the page, he/she is supposed to check the traits that apply to him/her and then click the submit button. What it does now is take ALL of the traits and then put them into a table called "Answers" and write the traitid (the unique id for the trait) in the field called (you guessed it) traitid, the author in the author field, and the value in the value field.
Here is the problem:
In the value field, it should write a 1 or a 0 depending if the check box was checked or not. The problem is that if I check the box, the it inserts the 1 or 0 for all of the records instead of for the traits where the user selected them or not. Every insert should be 10 traits for example and for each of those traits, in the value field, it should have a 1 OR a 0 depending on whether or not a user checked the box.
Any help?
Zito
<%
fNumbers = Request.Form("selected")
fAuthor = Request.Form("author")
datecreate = Request.Form("datecreate")
responseid = Request.Form("responseid")
classid = Request.Form("classid")
zito = request.form("trait_id")
Dim mycon, MM_editRedirectUrl
Set mycon = server.createobject("ADODB.Connection")
mycon.ConnectionString = MM_ConnIdeal_STRING
MM_editRedirectUrl = "participant_choose1.asp?response=completed"
mycon.Errors.Clear
mycon.Open
fArray = Split(fNumbers, ",")
For Each i in fArray
strSQL = "INSERT INTO answers (traitid, author, datecreate, responseid, classid, value) VALUES ('" & i & "','" & fAuthor & "','" & datecreate & "','" & responseid & "','" & classid & "','" & zito & "')"
MyCon.execute(StrSQL)
Next
if request.form("submit") <> "" then
Response.Redirect(MM_editRedirectUrl)
end if
%>