|
-
Apr 18th, 2001, 09:18 AM
#1
Thread Starter
Lively Member
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
-
Apr 18th, 2001, 01:49 PM
#2
Frenzied Member
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
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Apr 19th, 2001, 12:26 AM
#3
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|