Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still with the movenext.!

Status
Not open for further replies.

johnshutt

Technical User
Apr 11, 2002
6
0
0
GB
Right this may seem like an identical thread but this time i've managed to get my question in too o:|

Right i am making a multiple choice quiz, i have a recordset called questions throught which i select the question number, the querstion itslef and the 4 answers.

I display the answers in a form so the user can check a box click submit and then move to the next question. heres wheer i'm havibn trouble.

When i clcik sumbit instead of doin the movenext (is this in the right place??) which i have higlighted. it simply opens another recordset.

my code is below, i can send the dbase asell if ur that interested. :)

Cheers.

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<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(&quot;ADODB.Connection&quot;)
Set Questions = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Set Answers = Server.CreateObject(&quot;ADODB.Recordset&quot;)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Conn.Open &quot;Provider =Microsoft.Jet.OLEDB.4.0;&quot; &_
&quot;Data Source = C:\Inetpub\ &_
&quot;Persist Security Info=False&quot; ' CONNECTION TO DATABASE

strSQL = &quot;SELECT * FROM questions&quot; 'QUESRY THE TABLE QUESTION FOR ALL RECORDS

Questions.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET

strSQL = &quot;SELECT * FROM student&quot; 'QUESRY THE TABLE ANSWERS FOR ALL RECORDS

Answers.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Curnq = questions(&quot;Question Number&quot;)
MyArray(Curnq)= Request.Form(&quot;Answer&quot;)
Response.Write Myarray(Curnq)

%>
<H2>You are currently on question number <%Response.Write Questions(&quot;Question Number&quot;)%><BR><BR><BR>

<%Response.Write Questions(&quot;Question&quot;)%><BR>



<form action=&quot;test.asp&quot; method=&quot;post&quot; name=Form>
<p><input TYPE=&quot;radio&quot; NAME=&quot;Answer&quot; VALUE=&quot;A&quot;><%Response.Write Questions(&quot;Answer A&quot;)%></p>
<p><input TYPE=&quot;radio&quot; NAME=&quot;Answer&quot; VALUE=&quot;B&quot;><%Response.Write Questions(&quot;Answer B&quot;)%></p>
<p><input TYPE=&quot;radio&quot; NAME=&quot;Answer&quot; VALUE=&quot;C&quot;><%Response.Write Questions(&quot;Answer C&quot;)%></p>
<p><input TYPE=&quot;radio&quot; NAME=&quot;Answer&quot; VALUE=&quot;D&quot;><%Response.Write Questions(&quot;Answer D&quot;)%></p>
<input type=&quot;submit&quot; Value =&quot;Forwards><%Questions.MoveNext%></form></H2>
</BODY>
</HTML>
 
Why don't you use this thread(Thread333-249800
), to make it much easier? it's exactly your situation

Regards,
Durug
 
right from reading this post i think i may be confusing the issue. what the problem is, when i click the movenext, it doesn't. it re-opens the recordset. I can display the first record and get the users response from the form, but the movenext doesn't work, or am i just thick???
 
If you reload the page, you can't just movenext, because on the reloaded page the recordset doesn't exist anymore (so it has to be created again).

With the thread mentioned above you will open the recorset each time but move directly to the next record.

I know there are some solutions to load the whole recordset on the client side in javascript or XML and move through the recorset without reloading the page (or creating a recordset), but it's pretty ahrd to implement.

Regards,
Durug
 
durug.

Right i've tried following the example in the thread you indicated. But i'm still having trouble. I tired the code, but was unsuccessful, it just looped continuosly.

So is there any other thoughts, or could you indicate in my code where these new sections are located.

On a different note, i'm also tryin to update a recordset in another &quot;project&quot; but the server returns the error that the recordset does not support this. I'm usin an ado connection like the one in my previous post.

Cheers for your help.
 
If you have for each question 4 answers then I would return only a single recordset to the page
select * from question inner join answer on question.id = answer.id which will bring me something like this

question1 answer1
question1 answer2
question1 answer3
question1 answer4
question2 answer1
question2 answer2
question2 answer3
question2 answer4
etc...

And then I would use the code from the thread mentioned above to display 4 records per page

question1 answer1
question1 answer2
question1 answer3
question1 answer4

When you click movenext the page will reload and
it will return only

question2 answer1
question2 answer2
question2 answer3
question2 answer4

Did you tryed that?

Regards,
Durug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top