I have a table with a select box and a dropdown box that I want to be disabled by default (for safety purposes). Now, when the edit button from jquery-tabledit is clicked, I want them to be enabled again. How could I achieve so? When clicking on Save, action_user_2.php gets called with [action] => edit, but I need to listen when edit button gets click on the same page so that I can change the select box to "select name='selectbox'" (removing disabled).
<!--User Approval-->
<td>
<form method='POST'>
if ($row_approved['admin_approved'] == 'Approved') {
echo "<select disabled name='selectbox' onchange='this.form.submit()'>
<option value='Approved' selected>Approved</option>
<option value='Disapproved'>Disapproved</option>
</select>";
} else if ($row_approved['admin_approved'] == 'Disapproved') {
echo "<select name='selectbox' onchange='this.form.submit()'>
<option value='Approved'>Approved</option>
<option value='Disapproved' selected>Disapproved</option>
</select>";
}
echo "
</form>
</td>
<!--User Roles-->
<td>
<form method='POST'>
<select disabled class='roles_checkbox' multiple='multiple' name="roles_checkbox[]"
onchange='this.form.submit()'>
</select>
<?php
echo "
</form>
</td>
<script>
$(document).ready(function () {
$('#editable_table').Tabledit({
// when click on save; action_user_2.php gets called
url: 'action_user_2.php', // where data will be sent
data: {approved_status: approved_status},
columns: {
identifier: [0, "user_id"],
editable: [[1, 'first_name'],
[2, 'last_name'],
[3, 'email']]
},
// hide the column that has the identifier
hideIdentifier: true,
// activate focus on first input of a row when click in save button
autoFocus: true,
// activate save button when click on edit button
saveButton: true,
restoreButton: false,
onSuccess: function (data, textStatus, jqXHR) {
var htmlString = "<?php echo 'User information has been updated'; ?>";
alert(htmlString);
// custom action buttons
if (data.action === 'delete') {
$('#' + data.id).remove();
}
}
});
});
$('#editable_table').DataTable();
</script>
action_user_2.php
$input = filter_input_array(INPUT_POST);
print_r($input);
console->network->action_user_2.php
Array ( [user_id] => 4 [first_name] => New [last_name] => User [email] => tes@gmail.com [action] => edit )
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…