tags:

views:

23

answers:

1

Hi, I have a multiple select box which appears when I click the link 'Share'. Now I want to get the values of the options selected. How do I do that? is it $('#userList').val()? And also I have a doubt whether I could wrote the value property of option like this: ?

   $(document).ready(function(){
 var flag=0;
 $('#share_form').hide();

            $('.Share').click(function(){
  if(flag==1){
   $('#share_form').hide('fast');
   flag=0;
  }
  else{
      $('#share_form').show('slow');
  flag=1;
      return false;
  }

  });

      });//ready

    <a href="#" class="Share">Share</a>
 <div id="share_form">
 <p>Select the users with whom you want to share the Form</p>

 <select id="userList" name="userList" multiple>
  <?php foreach($users as $user){  ?>
   <option value="$user['User']['name']"><?php echo $user['User']['name'];?></option>
        <?php }?>
 </select> 
    </div>
+2  A: 

Selectors/selected

$("#userList option:selected").each(function(){
  alert($(this).text());
});
Jonathan Sampson