kateyez44
05-21-2003, 10:36 AM
I have 2 list boxes on a page, and I need to change the options displayed in the 2nd list box depending on what option is selected in the 1st list box. The problem I'm having is that I can't figure out how to get the list box to refresh after clearing all of the options out of the list, then adding the new ones. I've tried window.history.go(0), but this just seems to make my page refresh in an infinite loop! :confused:
Here is the code for my 1st list box. In the ONCHANGE event, I call a function called f_lstSatisfactory:
<SELECT NAME = lstSatisfactory ONFOCUS="wStatus(this);" TITLE = "wStatus(this);"
ONCHANGE="f_lstSatisfactory(this);" ONMOUSEOVER="wStatus(this);" ONMOUSEOUT="wStatus('');"
ONBLUR="wStatus('');" TABINDEX = 76 ALT="wStatus(this);">
Here is the code for f_lstSatisfactory:
function f_lstSatisfactory(oField)
{
var oOptions = document.forms[0].lstExplain1;
clearOptions(oOptions);
reOptionExplain1(oField, oOptions);
return;
}
Here is the code for the clearOptions function:
function clearOptions(oOptions)
{
for(var i=oOptions.options.length-1;i>=0;i--)
{
oOptions.options[i] = null;
}
oOptions.selectedIndex = -1;
return;
}
And, finally, here is the code for the reOptionExplain1 function:
function reOptionExplain1(oField, oOptions)
{
var options = new Explain1();
if(oField.value == "Y")
{
for (var i = 0; i <= options.abbrYes.length-1; i++)
{
oOptions.options[i] = new Option(options.optionYes[i], options.abbrYes[i]);
}
oOptions.length = i
}else if(oField.value == "N")
{
for (var j = 0; j <= options.abbrNo.length-1; j++)
{
oOptions.options[i] = new Option(options.optionNo[j], options.abbrNo[j]);
}
oOptions.length = i
}
return;
}
I figure I'm missing something in the reOptionExplain1 function, but cannot figure out what that is. Please help, I'd appreciate it.
Here is the code for my 1st list box. In the ONCHANGE event, I call a function called f_lstSatisfactory:
<SELECT NAME = lstSatisfactory ONFOCUS="wStatus(this);" TITLE = "wStatus(this);"
ONCHANGE="f_lstSatisfactory(this);" ONMOUSEOVER="wStatus(this);" ONMOUSEOUT="wStatus('');"
ONBLUR="wStatus('');" TABINDEX = 76 ALT="wStatus(this);">
Here is the code for f_lstSatisfactory:
function f_lstSatisfactory(oField)
{
var oOptions = document.forms[0].lstExplain1;
clearOptions(oOptions);
reOptionExplain1(oField, oOptions);
return;
}
Here is the code for the clearOptions function:
function clearOptions(oOptions)
{
for(var i=oOptions.options.length-1;i>=0;i--)
{
oOptions.options[i] = null;
}
oOptions.selectedIndex = -1;
return;
}
And, finally, here is the code for the reOptionExplain1 function:
function reOptionExplain1(oField, oOptions)
{
var options = new Explain1();
if(oField.value == "Y")
{
for (var i = 0; i <= options.abbrYes.length-1; i++)
{
oOptions.options[i] = new Option(options.optionYes[i], options.abbrYes[i]);
}
oOptions.length = i
}else if(oField.value == "N")
{
for (var j = 0; j <= options.abbrNo.length-1; j++)
{
oOptions.options[i] = new Option(options.optionNo[j], options.abbrNo[j]);
}
oOptions.length = i
}
return;
}
I figure I'm missing something in the reOptionExplain1 function, but cannot figure out what that is. Please help, I'd appreciate it.