D'oh! It's always nice to have your wife show you up ;)
<pre>
//############################################################
//# Determines if the passed oElement has been changed by the user
//# NOTE: This is a heavely modified version of the code at:
http://codestore.net/store.nsf/unid/DOMM-4UTKE6?OpenDocument
//############################################################
//# Last Updated: July 29, 2004
function isElementChanged(oElement) {
//#### Determine the .toLowerCase'd .type of the passed oElement and
process accordingly
switch (oElement.type.toLowerCase()) {
case 'text':
case 'textarea':
case 'password':
//#### If the oElement's .value differes from it's .defaultValue,
return true
if (oElement.value != oElement.defaultValue) {
return true;
}
break;
case 'radio':
case 'checkbox':
//#### If the oElement's .checked value differes from it's
.defaultChecked value, return true
if (oElement.checked != oElement.defaultChecked) {
return true;
}
break;
case 'select-one':
case 'select-multiple':
var i;
var bDefaultValueSpecified = false;
//#### Traverse oElement's .options to determine if the developer
specified any as .defaultSelected
for (i = 0; i < oElement.options.length; i++) {
//#### If the current .option is set as .defaultSelected, flip
bDefaultValueSpecified and set i so we fall from the loop
if (oElement.options[i].defaultSelected) {
bDefaultValueSpecified = true;
i = oElement.options.length;
}
}
//#### Traverse oElement's .options
for (i = 0; i < oElement.options.length; i++) {
//#### If the developer set some .defaultSelected .options
if (bDefaultValueSpecified) {
//#### If the oElement's .selected value differes from it's
.defaultSelected value, return true
if (oElement.options[i].selected !=
oElement.options[i].defaultSelected) {
return true;
}
}
//#### Else there are not any .defaultSelected .options set, so if
the user has selected something other then the first .option, return true
else if (oElement.options[i].selected && i != 0) {
return true;
}
}
break;
}
//#### If we make it here, the oElement has not changed, so return
false
return false;
}
</pre>
D'oh! It's always nice to have your wife show you up ;)
<pre> //############################################################ //# Determines if the passed oElement has been changed by the user //# NOTE: This is a heavely modified version of the code at: http://codestore.net/store.nsf/unid/DOMM-4UTKE6?OpenDocument //############################################################ //# Last Updated: July 29, 2004 function isElementChanged(oElement) { //#### Determine the .toLowerCase'd .type of the passed oElement and process accordingly switch (oElement.type.toLowerCase()) { case 'text': case 'textarea': case 'password': //#### If the oElement's .value differes from it's .defaultValue, return true if (oElement.value != oElement.defaultValue) { return true; } break;
case 'radio': case 'checkbox': //#### If the oElement's .checked value differes from it's .defaultChecked value, return true if (oElement.checked != oElement.defaultChecked) { return true; } break;
case 'select-one': case 'select-multiple': var i; var bDefaultValueSpecified = false;
//#### Traverse oElement's .options to determine if the developer specified any as .defaultSelected for (i = 0; i < oElement.options.length; i++) { //#### If the current .option is set as .defaultSelected, flip bDefaultValueSpecified and set i so we fall from the loop if (oElement.options[i].defaultSelected) { bDefaultValueSpecified = true; i = oElement.options.length; } }
//#### Traverse oElement's .options for (i = 0; i < oElement.options.length; i++) { //#### If the developer set some .defaultSelected .options if (bDefaultValueSpecified) { //#### If the oElement's .selected value differes from it's .defaultSelected value, return true if (oElement.options[i].selected != oElement.options[i].defaultSelected) { return true; } } //#### Else there are not any .defaultSelected .options set, so if the user has selected something other then the first .option, return true else if (oElement.options[i].selected && i != 0) { return true; } } break; }
//#### If we make it here, the oElement has not changed, so return false return false; } </pre>