aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Text Field and default values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Text Field and default values" Watch "Text Field and default values" New topic
Author

Text Field and default values

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I have a few text fields setup in a web application. When the user click the calculate button it needs to take the fields add them together and then populate another cell with that value.
(kinda like a spreadsheet).
Is there anyway to initialize the value of the text field to 0 (zero)without having it show the 0 (zero)??
If I set value=0 in the tag, the 0 shows up. If I set a defaultValue=0 I still get NaN as a result if any field is left blank.
Thanx


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I would suggest storing the values of your text fields in variables before performing the calculation. Then perform the calculation on the variables instead of the text field values themselves. That way you can validate them and set them to 0 if they are "" before using them, and the user will not see the value in the text field.
[This message has been edited by Bodie Minster (edited March 21, 2001).]
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Thanx, that's what we did, we just set the value="" then ran if statements on each variable and if == "" then we set it = to 0
thanx...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Text Field and default values