Right here goes, i need to be able to cycle through a recordset and display each "row" at a time, for a simple multiple choice quiz. I can display the first record, button cannot movenext. Where do i put the recordset.movenext statement if i am using forms to post the user selection back to the same page.
I have tried this once and have found that instead of moving next and refreshing the screen it simply re-opens the recordset. any thoughts? the code is below, if u want the dbase aswell lemme know.
Cheers for any help (in advanced. )
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>CP2023 - Computer Networks</TITLE>
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
</SCRIPT>
</HEAD>
<BODY>
<%
dim Conn, Questions, Conn2, Answers
dim MyArray(20)
dim varBook
Set Conn = Server.CreateObject("ADODB.Connection"
Set Questions = Server.CreateObject("ADODB.Recordset"
Set Answers = Server.CreateObject("ADODB.Recordset"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Conn.Open "Provider =Microsoft.Jet.OLEDB.4.0;" &_
"Data Source = C:\Inetpub\ &_
"Persist Security Info=False" ' CONNECTION TO DATABASE
strSQL = "SELECT * FROM questions" 'QUESRY THE TABLE QUESTION FOR ALL RECORDS
Questions.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET
strSQL = "SELECT * FROM student" 'QUESRY THE TABLE ANSWERS FOR ALL RECORDS
Answers.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Curnq = questions("Question Number"
MyArray(Curnq)= Request.Form("Answer"
Response.Write Myarray(Curnq)
%>
<H2>You are currently on question number <%Response.Write Questions("Question Number"%><BR><BR><BR>
<%Response.Write Questions("Question"%><BR>
<form action="test.asp" method="post" name=Form>
<p><input TYPE="radio" NAME="Answer" VALUE="A"><%Response.Write Questions("Answer A"%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="B"><%Response.Write Questions("Answer B"%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="C"><%Response.Write Questions("Answer C"%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="D"><%Response.Write Questions("Answer D"%></p>
<input type="submit" Value ="Forwards"><%Questions.MoveNext%></form></H2>
</BODY>
</HTML>
I have tried this once and have found that instead of moving next and refreshing the screen it simply re-opens the recordset. any thoughts? the code is below, if u want the dbase aswell lemme know.
Cheers for any help (in advanced. )
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>CP2023 - Computer Networks</TITLE>
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
</SCRIPT>
</HEAD>
<BODY>
<%
dim Conn, Questions, Conn2, Answers
dim MyArray(20)
dim varBook
Set Conn = Server.CreateObject("ADODB.Connection"
Set Questions = Server.CreateObject("ADODB.Recordset"
Set Answers = Server.CreateObject("ADODB.Recordset"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Conn.Open "Provider =Microsoft.Jet.OLEDB.4.0;" &_
"Data Source = C:\Inetpub\ &_
"Persist Security Info=False" ' CONNECTION TO DATABASE
strSQL = "SELECT * FROM questions" 'QUESRY THE TABLE QUESTION FOR ALL RECORDS
Questions.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET
strSQL = "SELECT * FROM student" 'QUESRY THE TABLE ANSWERS FOR ALL RECORDS
Answers.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Curnq = questions("Question Number"
MyArray(Curnq)= Request.Form("Answer"
Response.Write Myarray(Curnq)
%>
<H2>You are currently on question number <%Response.Write Questions("Question Number"%><BR><BR><BR>
<%Response.Write Questions("Question"%><BR>
<form action="test.asp" method="post" name=Form>
<p><input TYPE="radio" NAME="Answer" VALUE="A"><%Response.Write Questions("Answer A"%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="B"><%Response.Write Questions("Answer B"%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="C"><%Response.Write Questions("Answer C"%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="D"><%Response.Write Questions("Answer D"%></p>
<input type="submit" Value ="Forwards"><%Questions.MoveNext%></form></H2>
</BODY>
</HTML>