aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to remember background color in a form field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to remember background color in a form field" Watch "How to remember background color in a form field" New topic
Author

How to remember background color in a form field

Yani Inay
Greenhorn

Joined: Jan 21, 2002
Posts: 3
Dear helping hands:
I have a form with many text input fields and the fields are located in a table. Initially the text input fields have some kind of background color.
I use an external .js file to do edit check on the fields passing the form as parameter. If any fields are wrong, the .js file will change the background color of that field to red and display an error msg for user to correct the error. Then the user will try to submit the form again and the .js file will again do the edit check. If the newly corrected field has no error, I want to change its background color to its initial background color.
How do I remember that initial background color in javascript? Becaus now the input background color is red at this point.
Any help will be appreciated,
Soft Music
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Hi Yani Inay,

Declare a hidden variable in the form to store the current background colour of the form. Based on validation update the value of colour in the hidden variable.
That's how you will not loose the background value.
Vijay


SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Yani Inay",
Nice try!
Except that your new name still doesn't match the JavaRanch naming policy.
In particular:
Obviously fictitious names, or improperly formatted names may be locked out

The naming policy was a decision made by Paul Wheaton (Javaranch creator). He says:
I want to maintain a professional exchange on JavaRanch so that corporate america won't feel embarassed to find employees spending time here.

Basically this means we try not to be militant about the naming policy, but there is a standard that has been set that we have decided to follow and we require you to register with a valid name.
thanks for your co-operation.
Dave
ps Sorry about the hard-line attitude , it's worth registering and sticking around tho, I promise!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to remember background color in a form field