View Single Post
  #2 (permalink)  
Old 06-28-06, 01:38 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
You can't use decimals because you use parseInt, which by definition treats your numbers as Integers.
Use parseFloat to get a Float type instead. (That is a number where the decimal sign floats around and can be in any location).
One thing to note is that if JavaScript encounters a string beginning with 0, it might convert this string into an octal number (base 8) instead of a decimal number (base 10). To force base 10, do parseFloat(theString, 10).

You can also simplify the code slightly by removing the quotes around numbers in calls to buttonclick(). JS will automatically treat numbers as strings if they are added to other strings.
You can also replace
Code:
tdDisplay.innerHTML=tdDisplay.innerHTML+somethingElse
with
tdDisplay.innerHTML+=somethingElse
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote