Hi,
I am working on some javascript to let the parent document know if something has changed in the frame.
When the frame loads, it calls the addOnChangeHandler method below which iterates through all the elements in the form and adds an onchange handler which informs the parent if a field has changed.
The part which I have a problem with (highlighted in red) is avoiding overwriting any existing onChange handlers. How can I add the fieldChanged function to an existing onChange handler?
[CODE]
function addOnChangeHandler()
{
for (nIndex = 0; nIndex < detailsForm.elements.length; nIndex++)
{
if (detailsForm.elements[nIndex].type == ‘text’ ||
detailsForm.elements[nIndex].type == ‘textarea’ ||
detailsForm.elements[nIndex].type == ‘select-one’ ||
detailsForm.elements[nIndex].type == ‘select-multiple’)
{
if (detailsForm.elements[nIndex].onchange == null)
{
detailsForm.elements[nIndex].onchange = new Function(‘fieldChanged()’);
}
else
{
[COLOR=red]detailsForm.elements[nIndex].onchange += new Function(‘fieldChanged()’);[/COLOR]
} // end-if existing onchange
}// end-if changeable field
} // end for
} // End addOnChangeHandler
function fieldChanged() {
parent.setModified(true);
}// End fieldChanged
Thanks,
sabretooth