Page 1 of 1

How do I tell when a field has changed on my html form?

Posted: Sat Oct 17, 2009 3:47 pm
by dkperez
I have a form where a user retrieves a record. It's sitting on the screen.... The user can change one or more fields and I need to update the database record based on those changes.......

Is there a straightforward way (that doesn't require me to go retrieve the record from the database again) for me to tell if a field on my html form has changed?

There doesn't seem to be any way to do the equivalent of the "old value" "new value" comparison because the values don't persist once the form is presented. Once php retrieves the record and puts the fields into local variables that get displayed on the form, when the user hits "submit" to send their changes the old values aren't available... It seems silly to have two complete sets of fields on the form just so I have old and new values, but going to the database to get the old record seems pretty silly too... Is there a better way?

Re: How do I tell when a field has changed on my html form?

Posted: Sat Oct 17, 2009 4:08 pm
by califdon
That's one way to do it. It's not really silly, if that's what is required to get your job done. Another way would be to do it on the client side, using Javascript. The problem there is that it won't work if a browser has scripting disabled.