HI
I have an List box (<SELECT size=5 name="lst_avail" multiple>) that will accept multiple.
But how do I loop thru them and see which one is selected!
Easy.
Thanks;)
Printable View
HI
I have an List box (<SELECT size=5 name="lst_avail" multiple>) that will accept multiple.
But how do I loop thru them and see which one is selected!
Easy.
Thanks;)
You at least have the right idea already.. you have to loop through the option objects and check them...
Now, if you are talking about once the form is submitted, (Server Side processing) well, only the ones selected will be posted to the new page's Request.Form object so, you just need to either parse it(they will be comma delimited) or better yet, use the split function to stick the results into an array.
On the client side, a loop is required:
Code://Javascript
var colOptions = MyForm.lstMyListBox.options;
var intList;
for (intList=0; colOptions.length>intList; intList++)
if (colOptions[intList].selected)
window.alert(colOptions[intList].value + ' is selected');
Code:'VBScript
Dim colOptions
Dim intList
Set colOptions=MyForm.lstMyListBox.options
For intList = 0 to (colOptions.length-1)
If colOptions(intList).selected
window.alert colOptions[intList].value & " is selected"
End If
Next
Set colOptions = Nothing
Thank you very much! :)
I know how to do it in VB , but I couldn't figure it out in VBScript/Javascript.
Now I know :D