>I have a edit form in which the values already stored in DB are
>populated.
User can edit some or all the values in the form.
then he submit the form.
NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.
It is not uncommon to use hidden fields to contain the original values
of something so those values can be checked when the form is submitted.
This requires some manual effort. Yes, the original values can be
tampered with by the user, but since this user is authorized to edit
records anyway, there isn't much point.
>I HAVE TO COMPARE these values so that i can send only changed values
to server.
I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.
Regards,
Rider
Calm down. You don't have to yell to get help here.
If your data is stored in the db, then you should fetch the data from
the db again, and compare each item with its respective item in the form.
It is not uncommon to use the original values to check for multiple
editing of the same record by different people, especially in an
environment where people go to lunch or on extended vacations while
leaving the edit page open. This is used as a less-annoying
substitute for locking, which is impractical in a web-based environment
anyway.
You compare the original values on the page with the data from the
database. If they don't match, someone else has been editing the
page. You can tell what changes were made by this edit (original
form data vs. new form data) and what changes were made by the other
edit (original form data vs. database data). If you decide the
changes were conflicting, you can reject the change and ask the
user to do it again, showing them fresh original data. This also
works against the same user submitting the same change form twice.
Two separate changes to the 'salary' field are probably conflicting.
(One HR person was given instructions for a 5% raise for the
department; the other a 1% bonus for this employee. Two simultaneous
edits probably wipe out one or the other raise). A change to the
cell phone number and a change to the 'salary' field probably aren't.
>This should be done on the server end, not the client, which means all
data in the form goes to the server. Anything else would be unreliable.