Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
12-21-2010, 07:38 AM #1
- Join Date
- Dec 2010
- Thanked 0 Times in 0 Posts
Please help - simple script that won't work!
I am a very novice web coder and can't get this to work... I've tried everything and am getting no where but frustrated! Thanks in advance!!
12-21-2010, 08:16 AM #2
- Join Date
- Apr 2003
- Bucharest, ROMANIA
- Thanked 379 Times in 375 Posts
12-21-2010, 08:32 AM #3
- Join Date
- Jun 2002
- London, England
- Thanked 2,508 Times in 2,486 Posts
Homework? Have you tried using your error console? There are quite a few errors and you seem unaware of how to capture the value of a checked radio button.
a) Do not use eval!! Insecure and totally pointless here, but in any case mostly undesirable as there is almost always a better method.
b) Prefer to use the names of the form elements rather than elements - you should assign a name to your textbox.
c) You need to validate the value of lastBill entered into the textbox to ensure that it is a positive number. Obviously you cannot multiply a string value.
e) If you made the values of the radio buttons 0.01, 0.05 etc. then you would be able to take these directly as the value of frequencyRating.f) document.write statements must be run before the page finishes loading. You will have noticed that any document.write statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page. So document.write is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.Code:annualSavings = lastBill * frequencyRating;
BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.
"In the beginner's mind there are many possibilities, but in the expert's mind there are few” - Shunryu Suzuki (Japanese Zen priest, ?-1971)
Last edited by Philip M; 12-21-2010 at 12:25 PM. Reason: Noticed typo