I want to remove the disabled attribute of the text fields in a table when a user clicked the edit button from the selected row, but i don't know how I will filter the text fields that i want to change.
here is my php:
$query_select = "SELECT `users_id`,`users_studno`,`users_fname`,`users_lname`,`users_email`,`users_password` FROM `tbl_usersinfo` LIMIT 20";
if($run_query = mysqli_query($con,$query_select))
{
while($row = mysqli_fetch_assoc($run_query))
{
$id_val = htmlentities($row['users_id']);
$studno_val = htmlentities($row['users_studno']);
$fname_val = htmlentities($row['users_fname']);
$lname_val = htmlentities($row['users_lname']);
$email_val = htmlentities($row['users_email']);
$password_val = htmlentities($row['users_password']);
echo "<tr class = 'special_rows'>";
echo "<td>"."<input type = 'checkbox' value = 'id_val' style = 'cursor:pointer; '>"."</td>";
echo "<td>".$id_val."</td>";
echo "<td>"."<input type = 'text' value = '$studno_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$fname_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$lname_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$email_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$password_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<a style = 'cursor:pointer' class = 'edit'>edit</a> <a style = 'cursor:pointer' class = 'save'>delete</a>"."</td>";
echo "</tr>";
}
}
here is my jquery:
var edit = 0;
var save = false;
$('.edit').click(function()
{
if( edit %2 == 0)
{
$('#tbl_users').find('tr').click( function(){
alert('You clicked row '+ ($(this).index()) );
$(this).index().$('.data_field').removeAttr('disabled');
});
$(this).text('save');
}
else
{
$(this).text('edit');
}
edit++;
});
example: i clicked the edit button from the first row, all the first row textfields should remove all their disabled properties.