Easy Design

All About Design

Design Alert Box

without comments

design alert box
javascript (school project)?

For my psychology class I designed an experiment which is suppose to measure people’s visual memory. Here is the link to the webpage:

http://mlacomposer.com/color/main_page.htm

As you noticed, it shows alert boxes to tell you if you got the right or wrong answer but I want it to calculate the score and show it on the last frame. I used javascript (the only scripting language I know) but I can’t get it to calculate the score on the last frame because I don’t know how to transfer the data from one frame to another. I only know how to do this on the same webpage. Any help or tips of how I could go about doing this will be appreciated.

By the way I don’t know any other scripting languages so don’t tell me to use PHP or something.

Thanks in advance

Add the following to the script block for all pages from _d.htm forward.
var loc = window.location.toString();
var start = loc.indexOf(‘score=’) + ‘score=’.length;
var score = parseInt( loc.substring( start );

Replace your document.location set as follows:

For pages such as your _d.htm, in which a new test occurs, pass the sum of the previous score and the score for the test in that page to the next page as part of the location change
document.location = ‘page_e.htm?score=’ + score + (‘right’ == chosen)?1:0;

For pages such as your _e.htm, in which a no test occurs, just forward the previous score to the next page as part of the location change
document.location = ‘page_f.htm?score=’ + score;
…use this latter approach from your _m.htm to your score.htm, and the final, total score value will be available to JavaScript in the page. You can display it, using whatever approach you wish.

Creating A Smooth Contact Form with AJAX, PHP and MYSQL


Written by admin

January 9th, 2010 at 9:04 pm

Leave a Reply