Its for my OU course....
Im pretty much new to Java so im not overly sure what im doing. Basically, i have a script wich the purpose is to prompt for, store in a ariable, a numerical value wich is entered by the user, in a ranger from 1 to an upper limit determined by another variable. If the user fails to enter the value required in the range, the program will continue to ask the user to input a value. When an acceptable value is is input, the program should write that value to the output document. It is also assumed btw tht the users input is numeric.
Here is what i have done so far, though i am aware there are syntax errors and also some errors in logic wich is preventing the damn thing from running, can anyone help me debug this or help put me on the right lines? Thanks for your help! =)
Enter a number
var userInput;
var userNumber;
var upperLimit = 20;
userInput = window.prompt('Please enter a number in the range 1 to ' + upperLimit,'');
userNumber = parseFloat(userInput);
while ((userNumber = upperLimit))
{
UserInput = window.prompt('Please re-enter - number should be in range 1 to + upperLimit, '')
}
document.write(''+'Your chosen number was ' + yourNumber)
Posted By: Derek Acorah on May 27th 2007 at 14:13:41
Message Thread
- Is anyone any good with JavaScript? Im rather stuck with some code (n/m) (General Chat) - Derek Acorah, May 27, 12:47:39
- Depends how complex your code is... (General Chat) - Ben, May 27, 13:56:25
- Its for my OU course.... (General Chat) - Derek Acorah, May 27, 14:13:41
- Sorry that code appeard fucked up, try this..... (General Chat) - Derek Acorah, May 27, 14:14:56
- hmm ok, its not appearing properly when i post the message =/ (n/m) (General Chat) - Derek Acorah, May 27, 14:15:32
- Try this..... (General Chat) - Trent_Canary, May 27, 14:22:41
- That'll only work once - you need the while loop (General Chat) - BerlinCanary, May 27, 15:48:56
- Thanks, i think that will be applicable to part (b) of the question so ill give it a shot (n/m) (General Chat) - Derek Acorah, May 27, 14:24:57
- Try this..... (General Chat) - Trent_Canary, May 27, 14:22:41
- hmm ok, its not appearing properly when i post the message =/ (n/m) (General Chat) - Derek Acorah, May 27, 14:15:32
- Sorry that code appeard fucked up, try this..... (General Chat) - Derek Acorah, May 27, 14:14:56
- Its for my OU course.... (General Chat) - Derek Acorah, May 27, 14:13:41
- Depends how complex your code is... (General Chat) - Ben, May 27, 13:56:25
Reply to Message
In order to add a post to the WotB Message Board you must be a registered WotB user.
If you are not yet registered then please visit the registration page. You should ensure that their browser is setup to accept cookies.