Yes is me again. I didn't want to continue using the thread that someone else started, so, here goes.
OK, I've modified the code based on the input from both of you guys. The problem is that the second default still doesn't work, worse, I don't know what I'm doing wrong. Here's the code:
<cfoutput>
// first, remove all what is in the listbox
while (document.MyForm.PosID.options.length!=0)
document.MyForm.PosID.options.remove(0);
// now, fill it !
for (var m=0; m < #getPositions.RecordCount#; m++){
if (INV_ARRAY[2][m] == document.MyForm.GrpID.value){
var oOption = document.createElement("OPTION"
oOption.text=INV_ARRAY[1][m];
oOption.value=INV_ARRAY[0][m];
document.MyForm.PosID.options.add(oOption);
}
{
var sel2def = "#Select2_Default#";
if (INV_ARRAY[0][m] == sel2def)
document.MyForm.PosID.selectedIndex = INV_ARRAY[0][m];
}
}
</cfoutput>
I know for a fact that the second "if" is working because if I replace the last ("INV_ARRAY[0][m]" with a number, i.e. "6", the 6th option does get selected. But, it doesn't work when I use INV_ARRAY[0][m], I've even tried just "m" and still no go. What am I doing wrong??
OK, I've modified the code based on the input from both of you guys. The problem is that the second default still doesn't work, worse, I don't know what I'm doing wrong. Here's the code:
<cfoutput>
// first, remove all what is in the listbox
while (document.MyForm.PosID.options.length!=0)
document.MyForm.PosID.options.remove(0);
// now, fill it !
for (var m=0; m < #getPositions.RecordCount#; m++){
if (INV_ARRAY[2][m] == document.MyForm.GrpID.value){
var oOption = document.createElement("OPTION"
oOption.text=INV_ARRAY[1][m];
oOption.value=INV_ARRAY[0][m];
document.MyForm.PosID.options.add(oOption);
}
{
var sel2def = "#Select2_Default#";
if (INV_ARRAY[0][m] == sel2def)
document.MyForm.PosID.selectedIndex = INV_ARRAY[0][m];
}
}
</cfoutput>
I know for a fact that the second "if" is working because if I replace the last ("INV_ARRAY[0][m]" with a number, i.e. "6", the 6th option does get selected. But, it doesn't work when I use INV_ARRAY[0][m], I've even tried just "m" and still no go. What am I doing wrong??