Disable or hide items based on select list value
458506Jul 12 2006 — edited Jul 14 2006I've tried several javascript solutions from the forum but have only been partially successful. I want to hide or disable a text field when a particular value in a select list is selected, but I want it to remain hidden or disabled until a new value is chosen from the list, even after leaving the page and coming back to it. Select list = P51_SCHEDULE_TYPE and text field = P51_TOT_HOURS. Using 2.0, here's what I've tried:
Solution 1: using html_ShowItemRow and html_HideItemRow. This gives me an object expected error.
<script type="text/javascript">
function hideItem() {
var lCheck = html_SelectValue('P51_SCHEDULE_TYPE') == 21;
if (lCheck) {
html_ShowItemRow('P51_TOT_HOURS') ;
}
else {
html_HideItemRow('P51_TOT_HOURS');
}
}
</script>
select list form element: onChange="hideItem()"
Solution 2: Using disableItem. This one works once when you actually make the change in list. Upon re-visiting the page it is always enabled regardles of select list value.
<script type="text/javascript">
function disableItem(pThis) {
var lTest = (html_SelectValue(pThis) != "21")
html_disableItems(lTest, 'P51_TOT_HOURS');
}
</script>
Solutions 3...: Ive tried a combination of things including passing item id's or 'this' and putting the script in the page attributes and calling onLoad. I have a feeling I'm missing something obvious. Any help appreciated.