2009-07-13 11 views
0

[共有]リンクをクリックすると表示される複数の選択ボックスがあります。今度は、選択したオプションの値を取得します。それ、どうやったら出来るの?それは$( '#userList')です。val()? また、このようなoptionのvalueプロパティを記述できるかどうかは疑問です。選択ボックスの複数の値を取得する方法は?

$(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> 

答えて

3

セレクタ/ selected

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