Print Page | Close Window

variable transfer problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3618
Printed Date: 29 March 2026 at 11:56pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: variable transfer problem
Posted By: loic
Subject: variable transfer problem
Date Posted: 17 June 2003 at 5:23pm
Hi. I'm actually creating a language placement test.
Each page is composed of a bunch of exercises.
After clicking on the submit button (page1.asp), answers are automatically
corrected (page2.asp) and a score is given to the user.
So far, it’s pretty simple. Here’s a sample of the code which checks the
answers(page2.asp)


Page2.asp

<%
Dim answer1
Select case Request.Form ("1")
Case "yes"
answer1=1
Case "no"
answer1=0
End Select

Dim answer2
Select case Request.Form ("2")
Case "yes"
Answer2=1
Case "no"
Answer2=0
End Select

Dim total1
Total1=answer1+answer2
Response.Write total1
%>

Things get difficult (for me) when it comes to page3,4,5,6 …
In fact, the logic should be like:

page3.asp= total of “page1.asp”+ total of “page2.asp”
page4.asp= total of “page1.asp”+ total of “page2.asp” + total of “page3.asp” …..

My problem is that I don’t know how to call in page 3 a variable (like Dim total1)
I have set up in page 1. Instead, I’m asking the user in page 2 to re-enter his score
in a text-box form field (case) that I call in page 3. It looks like this:

<%
‘this is the total score for page1+page2
Dim totalpage1
Totalpage1=Request.Form ("case")
Dim totalpage2
Totalpage2=answer1+answer2+totalpage1
Response.Write totalpage2
%>

Well, it works fine but (1) it's annoying and (2) there's no integrity
at all as users can re-enter a fake score.


Does anyone have an idea how to simplify this procedure?
Something like having every single result stored in a buffer and being able to call
any variable anytime during the session.

Thanks in advance for your help.



Replies:
Posted By: michael
Date Posted: 17 June 2003 at 5:31pm
You could store it in a session variable.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: loic
Date Posted: 18 June 2003 at 1:04pm
Michael.

Thanks for your quick answer. I knew it would be something like this as I was referring to it at the end of my post. Anyone could provide me with a sample code to implement Michael’s answer? That would be great for me to have a concrete example I could work on.

Thks

Loic


Posted By: ljamal
Date Posted: 18 June 2003 at 3:26pm
Personally. I like to stay away from session variables as they are just glorified cookies. Just use a cookie to store the information.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: michael
Date Posted: 18 June 2003 at 3:52pm

If you use a cookie or session is up to you, cookie has the advantage that the user could pick it back up if he looses connection.
To get some insight on cookies check this site out: http://www.w3schools.com/asp/asp_cookies.asp - http://www.w3schools.com/asp/asp_cookies.asp



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: loic
Date Posted: 18 June 2003 at 4:17pm
this website looks good. Thanks Michael. Cookies have such a bad reputation that I wasn't sure it would be appropriate. Nevertheless, I'm going to give it a shot.

Someone else posted on another forum the following answer:

"couldn't you just pass the values from page to page by populating hidden text boxes?
you could just write the form and the values in one swoop:

<%
response.write("<form name='page1'>")
response.write("<input type='hidden' name='answ1' value=" & answer1 & ">")
response.write("<input type='hidden' name='answ2' value=" & answer2 & ">")
response.write("<input type='hidden' name='tot1' value=" & total1 & ">")
response.write("</form>")
%>

(the values will be populated by your SELECT CASE statements) couldn't you just pass the values from page to page by populating hidden text boxes?

FYI


Posted By: loic
Date Posted: 18 June 2003 at 5:16pm
quick question:

<% Response.Cookies("scorepage1") = value %>

I can't setup a definitive value (like 1,2, ...) as i've no idea what the score is going to be. Therefore I was wondering if a Cookie could equal a variable instead of a value? Something like:

<%
Dim score
score=answer1+answer2 ...
'cause I need the user to see his score
Response.write score
Response.Cookies("total")= ????   
'??? being the variable 'score' I would like to call
%>

Any idea or sugestion?






Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net