| Not a member yet? Register for FREE! |
| ||||||
| Science & Technology Discuss various technologies, finance and science. |
| JOIN TODAY! It's FREE . . . Discuss topics and issues that matter to you!
8,000 active members posting their views, facts and opinions on issues and topics that are important to people of today. Join a Discussion or better yet and Start a Discussion of your own! |
![]() |
| | Thread Tools |
| | #1 (permalink) |
| Just getting started Join Date: May 2007
Posts: 6
| Hi I kind of hitting Desperation point and really need a volenteer to help me out. Apart of my Open Uni course is about JavaScript and I am having problems getting my head around it... If there anyone out there willing to help me learn it I would be VERY grateful and it will mean the differents between passing and failing. If you willing to help me just click on reply. Thanks Toby ![]() |
| | |
| | #3 (permalink) |
| Just getting started Join Date: May 2007
Posts: 6
| Hi I was not expecting such a speedy response, which is very cool. What it 11.45pm now in the UK and I got to get up at 4am for work so I will add to this tomorrow if that o.k with you? Alternatively you could e-mail me at toby.whaymand@ntlworld.com Thanks Toby |
| | |
| | #6 (permalink) |
| Drank to much Mountain Dew | I recieved the following PM from Tobster: I got to fix the following programme and say what the errors are: <HTML> <HEAD> M 150 TMAO3 Question 1 (i) <TITLE>Enter a number </TITLE> <SCRIPT language="JavaScript" > 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 <= 1) || (userNumber >= upperLimit)) { UserInput = window.prompt('Please re-enter - number should be in range 1 to + upperLimit, '') } document.write('<BR>'+'Your chosen number was ' + yourNumber) </SCRIPT> </HEAD> <BODY> </BODY> </HTML> If could help me out I would be very greatful it will also help me learn. This does mean a lot to me so thanks Toby |
| | |
| | #9 (permalink) |
| Retired User Join Date: May 2007
Posts: 372
| Note: Blue indicates additions, green comments, red possible removals, and red italic removals <SCRIPT language="JavaScript" > var userInput; var userNumber; var upperLimit = 20; userInput = window.prompt('Please enter a number in' + //You need to terminate the string and use the + sign to concatenate the two strings if you're going to go to multiple lines 'the range 1 to ' + upperLimit,''); userNumber = parseFloat(userInput); //Need the ' to say it's a string and the default value is optional. Since you don't have anything useful in there, you might as well leave it out while ((userNumber <= 1) || (userNumber >= upperLimit)) { UserInput = window.prompt('Please re-enter - number' + 'should be in range 1 to' + upperLimit, ''); //Again terminate the string on the first line and use the + to concatenate. The text on the second line is not as a string so put the single quotes around it. Still nothing useful for the second part. Again, since it's optional, you can leave it out. //You also forget to check for valid input. If the user inputs invalid information the first time, they'll be stuck in an infinite loop. You need code here to fix that. } document.write('<BR>'+'Your chosen number was ' + //Why make that two strings? It's not necessary. yourNumberuserNumber); //yourNumber? It's been userNumber throughout the script </SCRIPT> It seems your biggest problem is just making a string cover multiple lines. You can always put each string on one line to avoid problems. Last edited by qtwerp : 06-02-2007 at 04:54 PM. Reason: cleanup |
| | |