jquery can't get the change event on select element

Posted by user63898 on Stack Overflow See other posts from Stack Overflow or by user63898
Published on 2012-09-29T14:59:21Z Indexed on 2012/09/29 15:37 UTC
Read the original article Hit count: 217

Filed under:
|

i have this code the jquery code never got triggered none of the scripts are triggered :

 $('select[name=privileges]').change(function(){
      alert("id");
            var id = $(this).find(':selected')[0].id;
            alert(id);
        $('#changevalue').val(id);
      }) 

or this:

   $("#privileges_select").change(function() {
        alert($('#privileges_select option:selected').html());
     });

  <form method="GET" action="create_new_user.php">          
         user:<input  type="text" size="40"   name="user_name"/> 
         password:<input  type="text" size="40"   name="password"/>       
          <select name=privileges  id="privileges_select">
          <option name='opt_1'>admin</option>
              <option name='opt_2'>ordinary</option>            
             </select>
         <input type="hidden" name="item_options_id" value="" id="changevalue" />

          <input type="submit" value ="create" />
          <input type="reset" />

       </form>

in the end i like to send the selected option id in the form get

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors