onchange update gender javascript
<p>My code doesn't work. When I change value of the <code>gender</code> select tag, the table doesn't update. <code>Address</code> works fine</p>

<pre><code>$(document).on('blur', '.address', function(){  
    var id = $(this).data("id4");  
    var address = $(this).text();  
    edit_data(id, address, "address");  
}); 

$(document).on('change', '.gender', function(){  
    var id = $(this).data("id5");  
    var gender = $(this).value();  
    edit_data(id, gender, "gender");  
}); 

function edit_data(id, text, column_name) {  
    $.ajax({  
        url: "edit.php",  
        method: "POST",  
        data: {
            id: id, 
            text: text, 
            column_name: column_name
        },  
        dataType: "text",  
        success: function(data) {  
             alert(data);  
        }  
   });  
}  
</code></pre>

<p>edit.php:</p>

<pre><code>&lt;?php  
    include 'database/connect.php';
    $id = $_POST["id"];  
    $text = $_POST["text"];  
    $column_name = $_POST["column_name"]; 
    $sql = "UPDATE agents SET ".$column_name."='".$text."' WHERE id='".$id."'";  

    if (mysqli_query($conn, $sql))  
    {  
        echo 'Data Updated';  
    }  
?&gt; 
</code></pre>

<p>select.php - this is where the datatable comes from</p>

<pre><code>&lt;td class="address" data-id4="'.$row["id"].'" contenteditable&gt;'.$row["address"].'&lt;/td&gt; 
&lt;td&gt;
     &lt;select class="gender" onchange="getval(this)" data-id5="'.$row["id"].'" &gt;
                    &lt;option value="Male" ' . ( $row["gender"]=='Male' ? 'selected' : '' ) . '&gt;Male&lt;/option&gt;
                    &lt;option value="Female" ' . ( $row["gender"]=='Female' ? 'selected' : '' ) . '&gt;Female&lt;/option&gt;
                 &lt;/select&gt;
&lt;/td&gt;
</code></pre>