FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Communicating between web pages

 


rameshbn1
Hi people,

I have a peculiar problem. I need a way to pass a variable between web pages. I don't have CGI, PHP, or any other way to do server side code.

This is how it should work:

    User visits a page, does something. A variable (an integer) is set based on this.
    User clicks 'next', and does something. The variable is incremented, decreased or left alone depending on the data entered.
    This goes on for a few more pages.
    On the 'final' page, the user gets to know the score.

Ok, I won't hide it anymore Smile I'm trying to do something like an online exam.
As I see it, I have two options:
    I might use javascript using cookies. I don't know much about cookies. Confused
    I could make an invisible frame and keep writing the variable into it using JS as the user moves along the test. I think I can do this but it doesn't seem elegant Wink

What's the expert's view on this?
LukeakaDanish
First thing:

Using javascript for an exam type thing sucks, because the clever student will just be able to click the address-bar and type in
Code:
javascript:score = 100000;
...Replacing "score" with whatever he found the variable to be by looking at your source code. - its VERY easy to cheat!

Second thing:

If you must do something liike this in javascript, i suggest opening a new window and then storing your variable in the parent window - this way you can increment it from the child window, and change the page without loosing the data.

If you would like some help with this, just ask/PM me or whatever...

Lastly:

If your doing this on frihost i suggest rethinking your "no php" tactic - php is VERY simple when you know javascript, so i think you should be able to handle making a simple quiz in it (with a little help from me Wink)
rameshbn1
Thanx LukeakaDanish,

I'm thinking of implementing the 'exam' on my frihost site, but that's a long way off in future. Right now, I'm trying to make a series of offline html exams for trainees at the place where I work... These guys are graduate chemists, so they aren't very likely to know much of Javascript Twisted Evil

But your reply has given me some ideas...
LukeakaDanish
rameshbn1 wrote:
...These guys are graduate chemists, so they aren't very likely to know much of Javascript Twisted Evil


I would NOT rely on that if i where you!

Javascript is VERY simple. Many people around the age of 10 years old know javascript. I suggest you install php/apache on your computer for this - or put the exam on your frihost with a password, and then let then use it from there.

PM me for assistance
ock1991
Perhaps you can make them answer everything and only check at the last page where the score is tabulated? Store the answers in its each cookie and validate them at the score page.

Of course, make them unable to press 'back' by checking a cookie which tracks the 'page' they were on?
htmlrules
have you ever tried using php as a sending tool it is very effective and is easy to do, the only problem being that i have only figured out how to send it using a form.

Code:
<form method="post" action="readform.php">
<input type="text" name="username"></input>
</form>

that being the code sending the information
Code:
<?php
   $inputvar = $_POST['username'];
echo "$inputvar"
?>

that script would be added to the readform page and would display watever the user had entered in the textfield
LukeakaDanish
htmlrules wrote:
have you ever tried using php as a sending tool it is very effective and is easy to do, the only problem being that i have only figured out how to send it using a form.

Code:
<form method="post" action="readform.php">
<input type="text" name="username"></input>
</form>

that being the code sending the information
Code:
<?php
   $inputvar = $_POST['username'];
echo "$inputvar"
?>

that script would be added to the readform page and would display watever the user had entered in the textfield


I think the reason he doesnt want to run php (correct me if im wrong), is because he is running the tests in a LOCAL enviroment...

I just had a sudden idea:

Why dont you use actionscript (flash) to do this? - its not as easy to "cheat" as it is in Javascript and with only a few hours of work, your javascript knowledge will become actionscript knowledge - because the two languages are ALTMOST identical.
rameshbn1
LukeakaDanish wrote:

I just had a sudden idea:

Why dont you use actionscript (flash) to do this? - its not as easy to "cheat" as it is in Javascript and with only a few hours of work, your javascript knowledge will become actionscript knowledge - because the two languages are ALTMOST identical.


YESSSS...... That's the answer. Thanks! Why didn't I think of it? Embarassed
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.