Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking to see if someone has updated a form

Status
Not open for further replies.

VBGuy2112

Programmer
Feb 19, 2002
58
US
Hello. I'm looking to write a generic function that will check all elements of a form to see if any field has been updated. What I mean is, I'd like to take a snapshot of all the values on a form when it's loaded and then check it at submission time to see if the user has changed any of the fields. If it's changed, then I want to update a record and create an audit trail.

I'd like to have this be a generic function that will work on any form. Any ideas?

Thanks!
 
<body onload=&quot;GetFormData()&quot;>

<form ... onSubmit=&quot;CheckFormData()&quot;>
...
</form>

<script language=javascript>
var myDataArray = new Array();
function GetFormData() {
for (i=0;i<document.forms[0].elements.length;i++)
{
myDataArray = document.forms[0].elements.value
}
}
function CheckFormData()
{
for (i=0;i<document.forms[0].elements.length;i++)
{
if (document.forms[0].elements.value!=myDataArray) {
alert(document.forms[0].elements.name + &quot; has changed&quot;); }
}
}
</script>
 
Thank you for the prompt reply. I will try this.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top