Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    highlight row color when field updated?

    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?

  • #2
    Regular Coder Common's Avatar
    Join Date
    Jan 2009
    Location
    Glasgow, UK
    Posts
    133
    Thanks
    16
    Thanked 13 Times in 13 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •