Results 1 to 3 of 3

Thread: Easy HTML question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    118

    Cool

    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

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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..

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    118
    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
  •  



Click Here to Expand Forum to Full Width