update stt- Too few parameters. Expected 1.
let me tell u what the code deos:
retrieve data ( text box, 2 radio buttons, ) from db.
on selection of any of the radio buttons, the counter should be appended.
in the database i have these field, question, option1,option2,option1_ctr,option2_ctr.
if option1 is clicked, then option1_ctr should be incremented.
<%
Dim Conn 'Holds the Database Connection Object
Dim RS 'Holds the recordset for the records in the database
Dim mySQL '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
rs.movefirst
clr=1
ques=rs("question")
session("ques")=ques
yes_ctr=rs("option1_ctr")
no_ctr=rs("option2_ctr")
opt1= rs("option1")
opt2 =rs("option2")
response.write "yes" & yes_ctr
response.write "no" & no_ctr
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<SCRIPT language="JavaScript">
function testButton (form){
var y_ctr;
var n_ctr;
y_ctr = <% =yes_ctr %>
n_ctr = <% =no_ctr %>
if (form.ans[0].checked)
{
y_ctr=y_ctr+1;
document.array.hid_code_y.value=y_ctr;
document.array.hid_code_n.value=n_ctr;
}
else
{
n_ctr=n_ctr+1;
document.array.hid_code_n.value=n_ctr;
document.array.hid_code_y.value=y_ctr;
}
document.array.submit();
}
</script>
</head>
<body>
<%
response.write"<form name='array' method='post' action='post.asp'>"
response.write"<table valign='top' border=1 align=center width='80%' cellpadding=0 cellspacing=0>"
response.write"<tr><td width='70%'>" & ques & "</td>"
response.write"<td width='6%'><input type='radio' onClick='testButton(this.form)' name='ans'>" & rs("option1") & "</td>"
response.write"<td width='6%'><input type='radio' onClick='testButton(this.form)' name='ans'>" & rs("option2") & "</td>"
clr=clr+1
response.write "</table>"
response.write "<input type='hidden' name='hid_code_y'>"
response.write "<input type='hidden' name='hid_code_n'>"
response.write"</form>"
y_ctr=request.Form("hid_code_y")
n_ctr=request.Form("hid_code_n")
execSQL="update pollz set option1_ctr=" & y_ctr & ",option2_ctr=" & n_ctr &" where question=" & session("ques")
response.write execSQL
'Conn.execute(execSQL)
RS.Close
Set RS = Nothing
Set Conn = Nothing
%>
</body>
</html>
|