AboutSrini Nagarajan Expertise I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase
Experience Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
Question i retrieve 3 fields from a db.
question1 option1 option2
question2 option2 option2
question - text box option1 - radio option2 - radio
i display all the records in a page
if option1 is clicked,option1_ctr of the particular row should be incremented
here is the code:
<%
Dim Conn 'Holds the Database Connection Object
Dim RS 'Holds the recordset for the records in the database
Dim mySQL1 'Holds the SQL query to query the database
Dim execSQL
Dim ques
Dim opt1
Dim opt2
Dim y_ctr
Dim n_ctr
Dim theform
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "DSN=pollz"
Conn.Open
mySQL = "SELECT * FROM pollz"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open mySQL, Conn,3,3
rcount=rs.recordcount
myArraySize=rcount
Dim rbArr()
Redim s(rcount,2)
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<SCRIPT language="JavaScript">
function testButton (form){
var y_ctr;
var n_ctr;
var quest;
var s =[];
y_ctr=<%=yes_ctr%>
n_ctr=<%=no_ctr%>
Loop
%>
<%If request.Form("insrow")="1" Then
y_ctr=request.Form("hid_code_y")
n_ctr=request.Form("hid_code_n")
ques=request.Form("quess")
MYSQL1 = "UPDATE pollz SET option1_ctr = " & y_ctr &", option2_ctr =" & n_ctr &" where question='" & ques & "'"
response.write mysql1
Conn.execute(mysql1)
End If
RS.Close
Set RS = Nothing
Set Conn = Nothing
%>
</body>
</html>
Answer Hi
What exactly you want the output? why do you want in array?
What is the alert is displaying for you.
my suggession is create a hidden variable and add all the question id and answer with comma delimited and read the hidden variable in you code to update. the output of the hidden variable should
q1^2,q2^1,q3^1....
means
question1 answer is option2
question2 answer is option1
question3 answer is option1...
using instr and split you should be able to retrieve the value in your ASP side