Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting values from text field

Status
Not open for further replies.

arunjp

Programmer
Jan 10, 2001
29
US
Hi !
I have a form which has text fields and I got to do some addition based on the values in each textfield. The problem is, Iam using eval(document.formname.elements[index].value) to get the value from each field. It works fine if I enter the number without zero in front i.e., say 345 and 333. But if I enter the same value like this i.e., say 0345 and 333, the sum Iam getting is weird. Since the entered data could also be negative so I cannot use Math.abs also. Is there any way to get the number as it is (even if zero in the beginning) and should also work for negative numbers, also netscape4.71 compatible.
Thanks
Arun
 
Probably the octal number confusion. Use parseFloat(document.formname.elements[index].value) instaed of eval. That should pose no problems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top