SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: help

  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    d
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help

    Hi im trying to learn javascript but i am completly stuck

    In the script below which is a higher/lower javascript game. when the player wins, a box comes up saying congratulation, click the button to play again. I want to know how to make that re-play button load another url instead of starting a new game.
    Can you help????????

    Many thanks
    luke

    <SCRIPT LANGUAGE="JavaScript">
    <!-- ;
    // numberguess is by Lancer - written 4 Jan 1999
    // lancer@kp.planet.gen.nz

    var guessme=Math.round(Math.random()*(99)+1);
    var speech='Guess my number (from 1 to 100)';

    function process(mystery) {
    var guess=document.forms.guessquiz.guess.value;
    var speech='"'+guess+ '" does not make sense to me.';
    document.forms.guessquiz.guess.value='';

    if (guess==mystery)
    {
    document.forms.guessquiz.prompt.value='Congratulations! '+mystery+' is correct!';
    alert ('Well done - the mystery number is '+mystery+'! \n\nPress this button to reload the page for another game.');
    speech='';
    document.location=document.location;
    }

    if (mystery<guess)
    {
    speech='Less than '+ guess;
    }

    if (mystery>guess)
    {
    speech='Greater than '+ guess;
    }

    if (guess=='')
    {
    speech='You didn\'t guess anything!'
    }

    document.forms.guessquiz.prompt.value=speech; document.forms.guessquiz.guess.focus();

    }

    // end hide -->
    </SCRIPT>

    <FORM onSubmit="" NAME="guessquiz">
    <CENTER>
    <TABLE ALIGN="CENTER" BGCOLOR="#888888" BORDER="3" CELLPADDING="5">
    <TR>
    <TD BGCOLOR="#004080">
    <FONT COLOR="#ffffff" FACE="Arial"><B>GUESS MY NUMBER (1 - 100)</B></FONT>
    </TD>
    </TR>
    <TR>
    <TD>
    <CENTER>
    <INPUT TYPE="text" NAME="prompt" SIZE="31" MAXLENGTH="40" VALUE="Guess my number (from 1 to 100)"><BR>
    <INPUT TYPE="text" NAME="guess" SIZE="3" MAXLENGTH="3" VALUE="">
    <INPUT TYPE="button" VALUE="Guess" onClick='process(guessme)'>
    </CENTER>
    </TD>
    </TR>
    </TABLE>
    </CENTER>
    </FORM>

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    if (guess==mystery)
    {
    alert ('Well done - the mystery number is '+mystery+'!');
    document.location="newpage.html";
    }
    Change newpage.html to the page you want to redirect the user to.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •