This JavaScript function determines if the contents of a specific control have been modified by the user since the page loaded.
This is accomplished by comparing the current value of a specific control with the custom attribute OldValue stored in the control when the page is loaded.
In the case of checkboxes and radio buttons, the custom attribute is oldchecked.
yfcHasControlChanged(ctrl)
ctrl - Required. Object in the HTML object hierarchy.
true - Value of the specified control is different from when the page was first loaded.
false - Value of the specified control is the same as when the page was first loaded.
This example shows how the Order Modification Reasons pop-up window uses this function to set the Override Flag in a hidden field.
The hidden field is passed to the changeOrder() API only when a specific field (for example, requested ship date) that is permitted to be changed only by users with special override permissions is changed by the user. This function detects if any of the input in the screen has changed.
function setOverrideFlag(overrideFlagBinding) {
var overrideFlagInput=document.all(overrideFlagBinding);
var docInputs=document.getElementsByTagName("input");
for (var i=0;i<docInputs.length;i++) {
var docInput=docInputs.item(i);
if (docInput.getAttribute("yfsoverride") == "true") {
if (yfcHasControlChanged(docInput)) {
overrideFlagInput.value="Y";
return;
}
}
}
var docSelects=document.getElementsByTagName("select");
for (var i=0;i<docSelects.length;i++) {
var docSelect=docSelects.item(i);
if (docSelect.getAttribute("yfsoverride") == "true") {
if (yfcHasControlChanged(docSelect)) {
overrideFlagInput.value="Y";
return;
}
}
}
}