Topic awaiting preservation: I think I am right, but not work..... (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: NZ |
posted 05-19-2003 23:59
Hi, guys. How are you today? Would you please see my code??? code: <html>
|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 05-20-2003 09:14
Well, the reason it's not working is that you're using this strange "2(...)" notation. Perhaps you mean "2*(...)"? In any case, the browser should be giving you an error message. In IE, for instance, check the lower left of the browser and the status bar should say there's an error message. Double click on that to get information about the error. Be sure to click "previous" until you get to the first error. I also recommend checking the checkbox that makes IE alert you about errors right when they happen. quote:
|
Nervous Wreck (II) Inmate From: Indianapolis, In USA |
posted 05-20-2003 13:43
I've found Mozilla to be very helpful when debugging javascript. It's Javasctip console tool will show you exactly where the error is. I won't leave home without it. |
Paranoid (IV) Inmate From: NZ |
posted 05-20-2003 23:04
Hi, Slime. Hi, rickindy! code: document.theForm.text6.value=4*(document.theForm.text1.value+document.theForm.text2.value+document.theForm.text3.value)
|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 05-22-2003 09:55
Mathematically, those two statements are equivalent. However, the values of text inputs are not numbers, they're *strings* (that is, if you type in "44", the text box doesn't contain the number 44, it contains the string consisting of two '4' characters). So JavaScript isn't doing *math* in the first one - it's appending the strings together. It only starts doing math when it seeds the multiplication operator (*), since it can't do multiplication with strings. In the second statement you gave, it does math right away, because it sees the multiplication operator right away. code: document.theForm.text6.value=4*(parseFloat(document.theForm.text1.value)+parseFloat(document.theForm.text2.value)+parseFloat(document.theForm.text3.value)) |
Paranoid (IV) Inmate From: NZ |
posted 05-22-2003 11:38
Hi, Slime. Many many thanks for your reply. |
Paranoid (IV) Inmate From: NZ |
posted 05-22-2003 23:25
Hi, slime. |