File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Removing the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Removing the "null" test from textfields" Watch "Removing the "null" test from textfields" New topic

Removing the "null" test from textfields

Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295

I need some idea in this regard.

The Scenario :

I have a page, where I have to display some fields, which are brought from database.

Before the records are fetched, the textfields show "null". I can get rid of this using script.

I want to know whether, we can make a generalized script, which could be used to check all the textfields, in a page and then, set a value of "", when it is null?

Is there a way to get all the textfields in a script?

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
This code may be what you are looking for:

You call it with:

There is one problem with this logic, if a person has JavaScript disabled, then the field values will still be set to the inital value since the code can not run.

Consider Paul's rocket mass heater.
subject: Removing the "null" test from textfields
It's not a secret anymore!