Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

ubdat records in database using checkboxes

Posted 25 Sep 2006 10:51:26
1
has voted
25 Sep 2006 10:51:26 Sakina Allawati posted:
hello

I want to update records by using checkboxes. I'm using asp code in dreamweaver
i have created tow pages one which have the checkboxes(question2.asp) and other one for update(vote2.asp)

this is my pages

question2.asp



<%
Dim rsAnswer2
Dim rsAnswer2_numRows

Set rsAnswer2 = Server.CreateObject("ADODB.Recordset"
rsAnswer2.ActiveConnection = MM_srcsurvey_conn_STRING
rsAnswer2.Source = "SELECT answers.answer_no, answers.Question_No, answers.answers, answers.counts FROM answers, questions WHERE questions.Question_No= answers.Question_No and questions.question_no=2"
rsAnswer2.CursorType = 0
rsAnswer2.CursorLocation = 2
rsAnswer2.LockType = 1
rsAnswer2.Open()

rsAnswer2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsAnswer2_numRows = rsAnswer2_numRows + Repeat1__numRows
%>
body part

<form method="get" action="localhost:88/src_survey/vote2.asp" name="form1">
<table width="477" >
<tr valign="baseline">
<td width="81" align="right" nowrap> </td>
<td colspan="2"> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Question No:</td>
<td width="230"><%=(rsAnswer2.Fields.Item("Question_No".Value)%></td>
<td width="150">Counts:</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsAnswer2.EOF))
%>
<tr valign="baseline">
<td nowrap align="right"></td>
<td valign="top">
<input type="checkbox" name="answers1" value="<%=(rsAnswer2.Fields.Item("answer_no".Value)%>" >
<option value="<%=(rsAnswer2.Fields.Item("answer_no".Value)%>"><%=(rsAnswer2.Fields.Item("answers".Value)%></option>       </td>
<td valign="top"><%=(rsAnswer2.Fields.Item("counts".Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsAnswer2.MoveNext()
Wend
%>
</table
<p align="center">
<input type="submit" name="Submit" value="Next">
</p>
</form>

<%
rsAnswer2.Close()
Set rsAnswer2 = Nothing
%>


vote2.asp

<%
strIDs = Replace(Request.querystring, "&answer_no=", ","
strIDs = Replace(strIDs, "answer1=", ""


set cmdUpdateAns = Server.CreateObject("ADODB.Command"
cmdUpdateAns.ActiveConnection = MM_srcsurvey_conn_STRING
cmdUpdateAns.CommandText = "UPDATE answers SET counts = counts + 1 where answer_no IN (" & strIDs & ""
cmdUpdateAns.CommandType = 1
cmdUpdateAns.CommandTimeout = 0
cmdUpdateAns.Prepared = true
cmdUpdateAns.Execute()

%>

this is not working
what is wrong with my code
please help

Reply to this topic