Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Erwino - tlHawkins - Pls Help - One more time

Status
Not open for further replies.

CidMatrix

IS-IT--Management
Jun 26, 2001
38
0
0
US
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(&quot;OPTION&quot;);
oOption.text=INV_ARRAY[1][m];
oOption.value=INV_ARRAY[0][m];
document.MyForm.PosID.options.add(oOption);
}
{
var sel2def = &quot;#Select2_Default#&quot;;
if (INV_ARRAY[0][m] == sel2def)
document.MyForm.PosID.selectedIndex = INV_ARRAY[0][m];
}
}
</cfoutput>

I know for a fact that the second &quot;if&quot; is working because if I replace the last (&quot;INV_ARRAY[0][m]&quot;) with a number, i.e. &quot;6&quot;, the 6th option does get selected. But, it doesn't work when I use INV_ARRAY[0][m], I've even tried just &quot;m&quot; and still no go. What am I doing wrong??
 
What is the value of #Select2_Default#?
When does this change? It looks like you are assigning the var sel2def to this and then never update this when you make a selection. If you create this variable as an input variable you can send the selected option to be used as selected Index.
example my_function(sel2def){
code ..
if (INV_ARRAY[0][m] == sel2def)
...
}
the first time you call the function, on loading the page call like: my_function(#Select2_Default)



Erwin Oosterhoorn
Analyst Programmer,
ice hockey player/fan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top