Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - variable transfer problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

variable transfer problem

 Post Reply Post Reply
Author
loic View Drop Down
Newbie
Newbie
Avatar

Joined: 17 June 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote loic Quote  Post ReplyReply Direct Link To This Post Topic: variable transfer problem
    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.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2003 at 5:31pm
You could store it in a session variable.
Back to Top
loic View Drop Down
Newbie
Newbie
Avatar

Joined: 17 June 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote loic Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
loic View Drop Down
Newbie
Newbie
Avatar

Joined: 17 June 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote loic Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
loic View Drop Down
Newbie
Newbie
Avatar

Joined: 17 June 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote loic Quote  Post ReplyReply Direct Link To This Post 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?



Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.