Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: is it possible to get the value of multiple selected fields through javascript


Message #1 by "Jacek Kaczocha" <jacek@w...> on Wed, 6 Dec 2000 18:13:09 -0000
Yes it is possible.
You have to run a loop and in that loop using an Index u have to check for

for(i=0,i<document.frm.selectBox.Count,i++)
{
    if(document.frm.selectBox.Options(i).Selected == true)
    {
       here you can addup into a Variable
    }

}

Just Check out whether the Options(i).property is Selected or
SelectedIndex.I guess one property returns True.Use that One.

----- Original Message -----
From: Jacek Kaczocha <jacek@w...>
To: javascript <javascript@p...>
Sent: Wednesday, December 06, 2000 11:43 PM
Subject: [javascript] is it possible to get the value of multiple selected
fields through javascript


> In the code below, I'd like to get the the value of multiple selected
> options. For instance, I select opt1 and opt2 and check() should display
> opt1 and opt2. Is it possible on the client?
>
>  <script>
>   function check()
>    {
>     alert(document.forms[0].???);
>    }
>  </script>
>
>  <form>
>
>   <select name="selectX" multiple>
>    <option name="opt1" value="opt1">opt1_text
>    <option name="opt2" value="opt2">opt2_text
>    <option name="opt3" value="opt3">opt3_text
>   </select>
>
>   <input type="button" value="OK" onClick="check()">
>
>  </form>
>

  Return to Index