E
E
Evgeny Elizarov2011-03-17 21:16:43
JavaScript
Evgeny Elizarov, 2011-03-17 21:16:43

Check the form - have any changes been made?

There is a large form like
text.field|text.field|checkbox|checkbox
...
Well, in general, editing a bunch of records from the database. How would you check whether changes were made in this line in any of the fields? And then every time to update all the records at once is somehow irrational. How would you mark this? JS on onclick somewhere to store id in a variable? Maybe somewhere smart that has already been written on this topic or who will throw an adequate thought?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WildZero, 2011-03-17
@WildZero

Hang up a function on onChange that will fill the hidden input with the flag changed / not?

J
Jazzist, 2011-03-17
@Jazzist

In any case, before writing, you will make one more selection - in order to check the existence of the element, check write permissions, and perform some security actions. You can compare the current data with the new ones in order to make a decision about the appropriateness of the update. If there is a lot of data, you can merge or serialize them and compare hashes, for example md5(implode()) - if there are changes, the hashes will be different.

M
Max Kuznetsov, 2011-03-17
@pluseg

So you answered your own question - save the original data in hidden inputs. You can, of course, check for changes on the server side, but why put extra load on the server, right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question