Is anyone here any good at JavaScript?

Discussion in 'General Discussions' started by NoPoint, Jun 24, 2007.

Thread Status:
Not open for further replies.
  1. NoPoint

    NoPoint Level III

    Joined:
    May 24, 2007
    Messages:
    621
    Likes Received:
    2
    Location:
    Somewhere on the Planet.
    I have an assignment with loads of javascript stuff to do and it is all fairly basic, but programming of any sort I cannot get my head round it.

    Anyone able to give me a hand?

    First Problem:

    <HTML>
    <HEAD> Enter a number
    <TITLE>Questionn 1 (ii)(a) </TITLE>
    <SCRIPT LANGUAGE = "JavaScript" >

    var userNumber;

    var upperLimit = 20;

    userNumber =
    window.prompt('Please enter a number in the range 1 to ' + upperLimit, '');

    userNumber = parseFloat(userNumber);

    while (userNumber < 1 || userNumber > upperLimit)

    {
    UserNumber =
    window.prompt('Please re-enter - number should be in range 1 to '
    + upperLimit, '');

    userNumber = parseFloat(userNumber)
    };

    document.write('<BR>'+'Your chosen number was ' + userNumber)

    </SCRIPT>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>

    For some reason this keeps getting stuck in a continous loop. If I enter a number between 1 and 20 it writes it, but then I enter a number outside the range, popup box appears (like its meant to), so then re-enter number inside range and popup box keeps appearing.
     
  2. Softxor

    Softxor Newbie

    Joined:
    Jun 23, 2007
    Messages:
    3
    Likes Received:
    0
Thread Status:
Not open for further replies.