H
hortoristic
We are using JavaScript to Enable/Disable certain fields on web pages
based on business rules.
A simple example is if when using an option type tag, and the two
options are Yes and No. If YES is selected - enable a field to use
the M$ Datepicker. Using the code below works for most of our fields,
however the problem is that when the field is re-enabled - it
remembers the original date or data prior to it being disabled -
despite the lines of code below that say oElement.value = '':
Is using oElement.value different when trying to clear out date values
and other types?
function mainDisable(oElement) {
// disable the specified page element
var sBgcolor = '#dddddd';
oElement.disabled = true;
oElement.imageUrl = '';
oElement.style.backgroundColor = sBgcolor;
// If the element is a select list, disable all the options, otherwise
// set the value to the empty string.
if (oElement.tagName == 'SELECT') {
// Clear all items in the select list.
for (i = 0; i < oElement.options.length; i++) {
oElement.options.selected = false;
oElement.value = '';
}
}
else {
oElement.value = '';
oElement.checked = false;
}
}
based on business rules.
A simple example is if when using an option type tag, and the two
options are Yes and No. If YES is selected - enable a field to use
the M$ Datepicker. Using the code below works for most of our fields,
however the problem is that when the field is re-enabled - it
remembers the original date or data prior to it being disabled -
despite the lines of code below that say oElement.value = '':
Is using oElement.value different when trying to clear out date values
and other types?
function mainDisable(oElement) {
// disable the specified page element
var sBgcolor = '#dddddd';
oElement.disabled = true;
oElement.imageUrl = '';
oElement.style.backgroundColor = sBgcolor;
// If the element is a select list, disable all the options, otherwise
// set the value to the empty string.
if (oElement.tagName == 'SELECT') {
// Clear all items in the select list.
for (i = 0; i < oElement.options.length; i++) {
oElement.options.selected = false;
oElement.value = '';
}
}
else {
oElement.value = '';
oElement.checked = false;
}
}