AJAX Forums

javascript hlep please?

This is a discussion on javascript hlep please? within the JavaScript forums, part of the Beginners AJAX category; Please look at the code carefully and attempt to identify each of the errorspresent. For each error, write a simple description of what is wrongwith the current codeHTML> M ...


Go Back   AJAX Forums > Beginners AJAX > JavaScript

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Old 06-23-2007, 08:34 AM   #1 (permalink)
 
Join Date: Jun 2007
Posts: 0
Rep Power: 0 PCworld is on a distinguished road
javascript hlep please?

Please look at the code carefully and attempt to identify each of the errorspresent. For each error, write a simple description of what is wrongwith the current codeHTML> M 150 TMAO3 Question 1 (i)Enter a number var userInput;var userNumber;var upperLimit = 20;userInput = window.prompt('Please enter a number inthe range 1 to ' + upperLimit,'');userNumber = parseFloat(userInput);while ((userNumber =upperLimit)){UserInput = window.prompt('Please re-enter - numbershould be in range 1 to + upperLimit, '')}document.write('<BR>'+'Your chosen number was ' +yourNumber)
__________________
PCworld is offline   Reply With Quote
Old 06-24-2007, 01:17 PM   #2 (permalink)
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 Custom-Computerz.com is on a distinguished road
Try:------------------------------------------------------------------------------------Enter a numbervar userInput;var userNumber;var upperLimit = 20;userInput = window.prompt('Please enter a number inthe range 1 to ' + upperLimit,'');userNumber = parseFloat(userInput);while ((userNumber =upperLimit)){UserInput = window.prompt('Please re-enter - numbershould be in range 1 to + upperLimit, '')}document.write('<BR>'+'Your chosen number was ' +yourNumber)------------------------------------------------------------------------------------Let me know if it works!
__________________
Custom-Computerz.com is offline   Reply With Quote
Old 06-25-2007, 02:46 AM   #3 (permalink)
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 Fallen is on a distinguished road
I have fixed the code above so that now it works.Here is the working code.Enter a number var userInput;var userNumber;var upperLimit = 20;userInput = window.prompt('Please enter a number in the range 1 to ' + upperLimit,'');while ((userNumber = upperLimit)){ userInput = window.prompt('Please re-enter - number should be in range 1 to + upperLimit', ''); userNumber = parseInt(userInput);}document.write('<BR>'+'Your chosen number was ' + userInput)I saw the following things wrong:1) I deleted this text "M 150 TMAO3 Question 1 (i)" as it causes an error.2) Enclosed the HTML tag, instead of "HTML>" it is now ""3) You use the variable yourNumber in "document.write('<BR>'+'Your chosen number was ' +yourNumber)" which is not declared.4) userNumber needed to be assigned after you assign userInput.5) In your while loop you are using a variable called "UserInput" which is not declared. JavaScript is case sensitive so I replaced it with "userInput"6) I added a text argument to the "" tag.7) In the line that says "UserInput = window.prompt('Please re-enter - numbershould be in range 1 to + upperLimit, '')" you need to have a single quote after "to" and before "+".
__________________
Fallen is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes



All times are GMT -4. The time now is 09:18 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com