Multiple Select box

Author Message
artic69

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 3/5/2005
  • Location:
  • Status: offline
Multiple Select box Saturday, March 05, 2005 9:15 PM (permalink)
0
Can somebody please tell me how to get the value of the selected item in a multiple select box using client side vbscript?

Thanks in advance
S
 
#1
    beaker

    • Total Posts : 82
    • Scores: 0
    • Reward points : 0
    • Joined: 1/27/2005
    • Location: USA
    • Status: offline
    Re: Multiple Select box Sunday, March 06, 2005 6:25 AM (permalink)
    0
    I did this just today. An example:
    <body>
    <select id="lstFType" size="1">
    <option value="1">Option1
    <option value="2">Option2
    <option value="3">Option3
    </select>
    <script language="vbscript>
    Dim intNewType
    intNewType = lstFType.options (lstFType.selectedIndex).value
    </script>
    
     
    #2
      artic69

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 3/5/2005
      • Location:
      • Status: offline
      Re: Multiple Select box Sunday, March 06, 2005 7:15 PM (permalink)
      0
      Thanks for you response.

      This is what the my code after reading your response

      document.frm.cmbMk.options(cmbMk.selectedIndex).value

      However, I get a "object required cmbMk" error message.

      I know cmbMk exists because

      msgbox document.frm.cmbMk.selectedindex

      returns the first item selected. This is however not what I want, I want all the items selected.

      Can you please help?

      Thanks



      quote:
      Originally posted by beaker

      I did this just today. An example:
      <body>
      <select id="lstFType" size="1">
      <option value="1">Option1
      <option value="2">Option2
      <option value="3">Option3
      </select>
      <script language="vbscript>
      Dim intNewType
      intNewType = lstFType.options (lstFType.selectedIndex).value
      </script>
      


       
      #3
        beaker

        • Total Posts : 82
        • Scores: 0
        • Reward points : 0
        • Joined: 1/27/2005
        • Location: USA
        • Status: offline
        Re: Multiple Select box Monday, March 07, 2005 1:50 AM (permalink)
        0
        So you are using a form. As my example shows, I don't use forms and don't know how to use them. I just put controls directly into the document. For testing, you might want to take the <select> element out of the form and see if you can get something more to work. However, this is really an HTML question more than a scripting question.
         
        #4
          Snipah

          • Total Posts : 1339
          • Scores: 8
          • Reward points : 0
          • Joined: 11/1/2004
          • Location: Scotland
          • Status: offline
          Re: Multiple Select box Monday, March 07, 2005 2:41 AM (permalink)
          0
          beaker: this is a Scripting q, not an HTML q.

          VBScript is supposed to read out the multiple values <select id="lstFType" multiple size="3">

          I am currently testing it (yet unresolved), but this is VB / JS related


           
          #5
            beaker

            • Total Posts : 82
            • Scores: 0
            • Reward points : 0
            • Joined: 1/27/2005
            • Location: USA
            • Status: offline
            Re: Multiple Select box Monday, March 07, 2005 3:30 AM (permalink)
            0
            Oh no, you are right about that, of course. Retrieving the values from the selection list is the scripting part, and handling the <form> submission is the HTML part. We can nail down the scripting syntax by taking the <select> element out of the <form> and just put it in the document. Then if the OP also needs help with the <form> processing, someone who knows how to do that should help.
             
            #6
              Snipah

              • Total Posts : 1339
              • Scores: 8
              • Reward points : 0
              • Joined: 11/1/2004
              • Location: Scotland
              • Status: offline
              Re: Multiple Select box Monday, March 07, 2005 4:24 AM (permalink)
              0
              i am well known with JavaScript / VBScript / HTML / DHTML and such, but this has never come across, therefore i see this as a challenge, but still unresolved.

              If the syntax is known in JS then no doubt there is a way in VBS, it only may take a few extra lines of coding...like attach the selections in a String or an Array

              [8)]
               
              #7
                token

                • Total Posts : 1917
                • Scores: 0
                • Reward points : 0
                • Joined: 1/14/2005
                • Location:
                • Status: offline
                Re: Multiple Select box Monday, March 07, 2005 6:51 AM (permalink)
                0
                Object cmbMK doesn't exist on its own, does it ?

                quote:
                I know cmbMk exists because
                msgbox document.frm.cmbMk.selectedindex


                What that means is that "document.frm.cmbMk.selectedindex" returns a value but it has nothing to do with "cmbMk.selectedIndex"

                I'm not familiar with client-side vbs, but what do you get if you change the line to:

                document.frm.cmbMk.options(document.frm.cmbMk.selectedindex).value ?

                I dont' even know if it means anything :P

                 
                #8

                  Online Bookmarks Sharing: Share/Bookmark

                  Jump to:

                  Current active users

                  There are 0 members and 1 guests.

                  Icon Legend and Permission

                  • New Messages
                  • No New Messages
                  • Hot Topic w/ New Messages
                  • Hot Topic w/o New Messages
                  • Locked w/ New Messages
                  • Locked w/o New Messages
                  • Read Message
                  • Post New Thread
                  • Reply to message
                  • Post New Poll
                  • Submit Vote
                  • Post reward post
                  • Delete my own posts
                  • Delete my own threads
                  • Rate post

                  2000-2012 ASPPlayground.NET Forum Version 3.9