Академический Документы
Профессиональный Документы
Культура Документы
DOCTYPE html>
<html>
<head>
<title>STUDENT INFORMATION</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<br />
<br />
</div>
<div>
<div>
</div>
</form>
</div>
<div class="table-responsive">
<tr>
<th>ID Number</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Contact Number</th>
<th>Email</th>
<th>Address</th>
<th>Date of Birth</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</body>
</html>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<div class="form-group">
<label>Enter ID Number</label>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label>Enter Middlename</label>
</div>
<div class="form-group">
<label>Enter Lastname</label>
</div>
<div class="form-group">
<label>Enter Gender</label>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label>Enter Email</label>
</div>
<div class="form-group">
<label>Enter Address</label>
<input type="text" name="address" id="address" class="form-control"/>
</div>
<div class="form-group">
</div>
<div class="modal-footer">
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
fetch_data();
function fetch_data()
$.ajax({
url:"fetch.php",
success:function(data)
{
$('tbody').html(data);
})
$('#add_button').click(function(){
$('#action').val('insert');
$('#button_action').val('Insert');
$('.modal-title').text('Add Data');
$('#apicrudModal').modal('show');
});
$('#api_crud_form').on('submit', function(event){
event.preventDefault();
if($('#id_no').val() == '')
alert("Enter ID Number")
alert("Enter Firstname");
alert("Enter Middlename")
alert("Enter Gender")
alert("Enter Email")
alert("Enter Address")
else
$.ajax({
url:"action.php",
method:"POST",
data:form_data,
success:function(data)
fetch_data();
$('#api_crud_form')[0].reset();
$('#apicrudModal').modal('hide');
if(data == 'insert')
if(data == 'update')
alert("Data Updated");
});
});
var id = $(this).attr('id');
$.ajax({
url:"action.php",
method:"POST",
data:{id:id, action:action},
dataType:"json",
success:function(data)
$('#hidden_id').val(id);
$('#id_no').val(data.id_no);
$('#first_name').val(data.first_name);
$('#middle_name').val(data.middle_name);
$('#last_name').val(data.last_name);
$('#gender').val(data.gender);
$('#contact_number').val(data.contact_number);
$('#email').val(data.email);
$('#address').val(data.address);
$('#date_of_birth').val(data.date_of_birth);
$('#action').val('update');
$('#button_action').val('Update');
$('.modal-title').text('Edit Data');
$('#apicrudModal').modal('show');
})
});
var id = $(this).attr("id");
$.ajax({
url:"action.php",
method:"POST",
data:{id:id, action:action},
success:function(data)
fetch_data();
});
});
});
</script>