Click to See Complete Forum and Search --> : form change


lcgray
09-02-2004, 02:28 PM
Hello,

I need to know if any of the elements in a form has changed with out putting an onchange on each element. Does anyone know a way to easily know if any of the data in the form has changed? This form has lots & lots of input fields.

Thanks,
Linda

AdamGundry
09-02-2004, 02:51 PM
Welcome to the forums. You will need to assign an onchange event handler to each field, but you can do it dynamically thus:
<script type="text/javascript">
var somethingChanged = false;

function reportChange(){
somethingChanged = true;
}

window.onload = function(){
for (var i=0;i<document.forms[0].length;i++)
document.forms[0][i].onchange = reportChange;
}
</script>
Adam