...

View Full Version : highlight row color when field updated?



nikko50
12-19-2010, 06:22 PM
I have some table rows with an item, item description and a text field named "qty" for the quantity. If a user types a number above 0 in the "qty" field, I would like it to highlight the table row. If a user gos back and deletes the number already in the text field I would like the table row to return to it's default state. How can I do this?

Common
12-20-2010, 10:11 AM
There's an event called blur which triggers when you click off or tab away from a text field, so on your text field tag would be something like this: <input type="text" id="field1" onBlur="changecolour();" value="0"> and you would also have defined a variable of the value 0 which represents to the javascript the value of field1.

Then, simple enough to write the function which will run in that instant. It would check it the the variable I just mentioned was equal to what was the current value of the input box, if not that means the number has been changed so run the script. This would be simple, just do a bit of error handling to make sure they haven't entered text or whatever you need for your requirements and if, in the end up the value of field1 is indeed > 0, change the colour of the row.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum