[Javascript] (no subject)

Robert Kidd clowns at gol.com
Tue Apr 17 12:10:23 CDT 2001


Hi!

I am setting up an intranet site for students of English and I have a theoretical question about Java Script. (I am a pre-beginner so please bear with me and if I make any Java Script "newbie" faux pas please ignore them ;)

First, I will have a test page to determine the students level and depending on the score they get on that test I would like the script to direct them to one of three pages corresponding to the different levels. For example:

if the student scores 50% or less then they would automatically be sent to page "A.html"
"       "       "       51% to 75% they would automatically get sent to page "B.html"
"       "       "       75% or higher they would automatically get sent to page "C.html"

 From skimming and scanning and searching through books and on the net I have put together the following code but I don't think it is that easy!

<script>

function JumpToResultPage(score)
{
     var resultPageUrl;
     if (score < 50)
          resultPageUrl = "a.html";
     else if (score < 75)
          resultPageUrl = "b.html";
     else
          resultPageUrl = "c.html";
     location.replace(resultPageUrl);
}

</script>

Or

<script>

function JumpToResultPage(score)
{
     location.replace( score < 50 ? "a.html"
               : score < 75 ? "b.html"
               : "c.html" );
}

</script>

Is it that simple?? Don't I need to have a database for the student's scores so that when they come back the next time they won't have to do the test again?? Where does this script get the scores from? Where do I implement this? Do I need something in the head tag or the body tag? One of the books also mentioned something (Sorry but as I said I am a raw beginner!) about the "submit handler" which is ...??

Secondly, is Javascript the best way to do this or is there some other language I should learn that would be better at this kind of thing, like PHP, Perle, VB, etc etc.???

I am trying to learn all this but my time is limited and I just need to get it to work so that I can show them how the site will work.

These pages are for an Intranet site specifically for the company I work for so I am afraid you can't view them at this time but any enlightening info at all it would be greatly appreciated. 

Bob





More information about the Javascript mailing list