Results 1 to 6 of 6

Thread: [RESOLVED] Multiple selection list boxes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    131

    Resolved [RESOLVED] Multiple selection list boxes

    I am trying to get data from a few list boxes, so I set up a stringbuilder to append the value selected, but how would that work with boxes that I set to "multiple selection"?

    Also, what is a more efficient way to reset a form other than settings everything to "" when the button is clicked?

    EDIT: Wow, remembered the onReset="return clearFields();.
    Last edited by meef; Aug 30th, 2007 at 01:22 PM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Multiple selection list boxes

    Loop through the .Items of the listbox and check for the .Selected property.

    vb Code:
    1. For Each li As ListItem in myListBox1.Items
    2. If li.Selected = True Then
    3. 'Add to stringbuilder
    4. End If
    5. Next

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    131

    Re: Multiple selection list boxes

    Thanks.

    So this is alright then?

    vb Code:
    1. For Each li As ListItem In lstOrgMain.Items
    2.             If li.Selected = True Then
    3.                 strBody.Append("Main Campus Organizations: " & li.Selected & "")
    4.             End If
    5.         Next

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    131

    Re: Multiple selection list boxes

    Eh I guess that doesn't work... What did I do wrong? I get this as a result:

    Main Campus Organizations: TrueMonroe Campus Organizations: TrueMonroe Campus Organizations: TrueIntramural Sports: TrueIntramural Sports: TrueIntramural Sports: TrueIntramural Sports: TrueIntercollegiate Sports: TrueIntercollegiate Sports: TrueIntercollegiate Sports: TrueSemester
    EDIT: Duh, should be "value" and not "selected".

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Multiple selection list boxes

    Does that edit you made mean that you solved the problem?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    131

    Re: Multiple selection list boxes

    Yep sorry, all is well with this issue now.

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