title: get the value of dropdown select options using ajax
body: <p>i am stuck,the select options value is sent but it sets the value to 0 all the time i execute the query. how can i get the value of the options to be grabbed ? i would be very grateful for the answer. thanks</p>
  
  <p>here is the form for the select options </p>
  
  <pre><code>            &lt;select name="user_role" id="#user_role"&gt;
                  &lt;option&gt;
                  &lt;/option&gt;
                  &lt;option value="1"&gt;
                      Super Admin
                  &lt;/option&gt;
                  &lt;option value="2"&gt;
                      Team Manager
                  &lt;/option&gt;
                  &lt;option value="3"&gt;
                      Staff
                  &lt;/option&gt;
              &lt;/select&gt;
  </code></pre>
  
  <p>the ajax function i set is </p>
  
  <pre><code>$(".save-update").click(function(e) {
                          e.preventDefault();
                          //alert("save button clicked");
                          var username = $("#username").val();
                          var email = $("#email").val();
                          var user_role = $("#user_role option:selected").val();
                          $.post("../lib/ajax/edit-user-save.php",{username:username,email:email,id:id,user_role:user_role},function(data){
                                  //alert(data);
                                  $(".save-update").parent().parent().addClass("table-list");
                                  $(".save-update").parent().parent().replaceWith(data);
                                  });
  
                  });
  </code></pre>
  
  <p>now, the edit-user-save.php where the query is done</p>
  
  <pre><code>if(isset($_POST['user_role'])){
              $user_role = $_POST['user_role'];
              //echo $id;
          }
  
      //$query = mysql_query();
      $query = mysql_query("UPDATE users SET username='$username', email='$email',user_role='$user_role' WHERE id=$id");
      if(!$query){
              echo "could not update the table".mysql_error();
          }
  </code></pre>