How to show form action result in modal - php

i want to show my action result in modal, after submit button is clicked, i want modal popup show my action result...........................................................................
This is html form
<form class="g-py-15" id="submit-button" action="<?php echo base_url('cekongkir/cek_ongkir') ?>" method="POST" role="form">
<div class="row">
<div class="col-xs-12 col-sm-6 mb-4">
<div class="form-group u-select--v3 g-pos-rel g-brd-none g-brd-bottom g-brd-gray-light-v7 rounded-0 mb-0">
<center><label><strong>From</strong></label></center>
<select name="province_id" id="provincefrom" onchange="loadCityfrom()" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" required="">
<?php
echo "<option value=''> Select Province</option>";
foreach ($province as $p) {
echo "<option value='$p->province_id'>$p->prov_name</option>";
}
?>
</select>
<div class="d-flex align-items-center g-absolute-centered--y g-right-0 g-color-gray-light-v6 g-color-lightblue-v9--sibling-opened g-mr-15">
<i class="hs-admin-angle-down"></i>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 mb-4">
<div class="form-group u-select--v3 g-pos-rel g-brd-none g-brd-bottom g-brd-gray-light-v7 rounded-0 mb-0">
<center><label><strong>To</strong></label></center>
<select name="province_id" id="provinceto" onchange="loadCityto()" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" required="">
<?php
echo "<option value=''> Select Province</option>";
foreach ($province as $p) {
echo "<option value='$p->province_id'>$p->prov_name</option>";
}
?>
</select>
<div class="d-flex align-items-center g-absolute-centered--y g-right-0 g-color-gray-light-v6 g-color-lightblue-v9--sibling-opened g-mr-15">
<i class="hs-admin-angle-down"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 mb-4" required="required">
<div class="form-group u-select--v3 g-pos-rel g-brd-none g-brd-bottom g-brd-gray-light-v7 rounded-0 mb-0" id="cityAreafrom" required="required">
<select class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" required>
<option value="">Select City</option>
</select>
<div class="d-flex align-items-center g-absolute-centered--y g-right-0 g-color-gray-light-v6 g-color-lightblue-v9--sibling-opened g-mr-15">
<i class="hs-admin-angle-down"></i>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 mb-4" required="required">
<div class="form-group u-select--v3 g-pos-rel g-brd-none g-brd-bottom g-brd-gray-light-v7 rounded-0 mb-0" id="cityAreato" required="required">
<select class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" required>
<option value="">Select City</option>
</select>
<div class="d-flex align-items-center g-absolute-centered--y g-right-0 g-color-gray-light-v6 g-color-lightblue-v9--sibling-opened g-mr-15">
<i class="hs-admin-angle-down"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 mb-4" required="">
<div class="form-group u-select--v3 g-pos-rel g-brd-none g-brd-bottom g-brd-gray-light-v7 rounded-0 mb-0" required="required" id="subdistrictAreafrom">
<select class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" required>
<option value="">Select Subdistrict1</option>
</select>
<div class="d-flex align-items-center g-absolute-centered--y g-right-0 g-color-gray-light-v6 g-color-lightblue-v9--sibling-opened g-mr-15">
<i class="hs-admin-angle-down"></i>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 mb-4" required="">
<div class="form-group u-select--v3 g-pos-rel g-brd-none g-brd-bottom g-brd-gray-light-v7 rounded-0 mb-0" required="required" id="subdistrictAreato">
<select class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" required>
<option value="">Select Subdistrict</option>
</select>
<div class="d-flex align-items-center g-absolute-centered--y g-right-0 g-color-gray-light-v6 g-color-lightblue-v9--sibling-opened g-mr-15">
<i class="hs-admin-angle-down"></i>
</div>
</div>
</div>
</div>
<div class="mb-4">
<center><label>Berat Barang</label></center>
<center>
<div class="col-6">
<input class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-15 g-px-15" name="username" type="text" placeholder="(Kg)" required="">
</div>
</center>
</div>
<footer class="text-center">
<div class="col-12">
<button type="submit" class="btn btn-block u-btn-primary rounded g-px-30 g-py-11 ml-1" >Cari Ongkir</button>
</div>
</footer>
</form>
how to call the modal after form action calling action in controller
<script type="text/javascript">
function loadCityfrom(){
var province = $("#provincefrom").val();
$.ajax({
type:'GET',
url:"<?php echo base_url(); ?>register/cityList",
data:"province_id=" + province,
success: function(html)
{
$("#cityAreafrom").html(html);
}
});
}
function loadSubdistrictfrom(){
var city = $("#city").val();
$.ajax({
type:'GET',
url:"<?php echo base_url(); ?>register/subdistrictList",
data:"city_id=" + city,
success: function(html)
{
$("#subdistrictAreafrom").html(html);
}
});
}
</script>
<script type="text/javascript">
function loadCityto(){
var province = $("#provinceto").val();
$.ajax({
type:'GET',
url:"<?php echo base_url(); ?>register/cityListto",
data:"province_id=" + province,
success: function(html)
{
$("#cityAreato").html(html);
}
});
}
function loadSubdistrictto(){
var city = $("#cityto").val();
$.ajax({
type:'GET',
url:"<?php echo base_url(); ?>register/subdistrictListto",
data:"city_id=" + city,
success: function(html)
{
$("#subdistrictAreato").html(html);
}
});
}
</script>
[Here my codepen]
https://codepen.io/hasta2103/pen/qBZmvjL

Related

How i fixed $data is undefined?

I have a problem while creating edit and create forms
I have a form that is used to create and edit when I call $data on the form so that it appears when editing the form.
But when I open the form to create new data the error $data is undefined appears.
This is my route
Route::resource('/tabungan/jadwal-autodebet', SavingAccountScheduleController::class);
This is the create and edit script in my controller
public function create()
{
$info['header'] = $this->title;
$info['description'] = 'Tambah';
$info['breadcrumb'] = null;
return view('banking::autodebet-schedule.form',$info);
}
public function edit($id)
{
$info['header'] = $this->title;
$info['description'] = 'Ubah';
$info['breadcrumb'] = null;
$data = TransactionSchedule::find($id);
$origin = clone $data;
$origin = $data->origin;
$destination = clone $data;
$destination = $data->destination;
$destinationType = '';
$saving = SavingAccount::class;
$loan = LoanAccount::class;
if($data->origin_type == $saving){
$destinationType = 'Tabungan';
}elseif($data->origin_type == $loan){
$destinationType = 'Pinjaman';
}
// dd($data,$origin,$destination);
return view('banking::autodebet-schedule.form',compact('data','origin','destination','destinationType'),$info);
}
and this is my autodebet.schedule.form script
<form id="formData" action="{{ isset($data) ? admin_url('cb/tabungan/jadwal-autodebet/'.$data->id) : admin_url('cb/tabungan/jadwal-autodebet/')}}" method="POST" autocomplete="off">
{{ csrf_field() }}
#if(isset($data))
{{method_field('PUT')}}
#endif
<div class="container d-flex justify-content-center">
<div class="col-12">
<div class="row">
<div class="col-2">
<label class="label-required" for="" >Produk Tujuan</label>
</div>
<div class="col-10">
<select name="destination_type" id="destination_type" class="select2 form-control destination_type">
<option value="{{ $data->origin_type }}">{{ $destinationType }}</option>
<option class="type_option" id="SavingAccount" value="Modules\Banking\Entities\SavingAccount">Tabungan</option>
<option class="type_option" id="LoanAccount" value="Modules\Banking\Entities\LoanAccount">Pinjaman</option>
</select>
</div>
</div>
<div class="row">
<div class="col-2">
<label class="label-required" for="">No Rekening Sumber</label>
</div>
<div class="col-10">
<select id="origin_code" class="select2 form-control origin_code">
<option value="{{ $origin->id }}">{{ $origin->saving_code }}-{{ $origin->customer->customer_name}}-{{ $destinationType }}</option>
</select>
</div>
</div>
<div class="row">
<div class="col-2">
<label class="label-required" for="" >Transaksi Rekening Anggota/Nasabah Lain</label>
</div>
<div class="col-10">
<input type="hidden" id="other_costumer_transaction" name="other_costumer_transaction" value="0">
<div class="az-toggle {{ 'off' }}" id="other_costumer_transaction_toggle"><span></span></div>
</div>
</div>
<div class="row">
<div class="col-2">
<label class="label-required" for="">No Rekening Tujuan</label>
</div>
<div class="col-10">
<select id="destination_code" class="select2 form-control destination_code" >
<option value="{{ $destination->id }}">{{ $destination->saving_code }}-{{ $destination->customer->customer_name}}-{{ $destinationType }}</option>
</select>
</div>
</div>
<div class="row" id="info-nasabah" style="display: none">
<div class="col-2">
</div>
<div class="col-10">
<h6>No. Rekening : <span id="info-kode">xxx.xxx.xxx</span></h6>
</div>
<div class="col-2">
</div>
<div class="col-10">
<h6>Nama Nasabah : <span id="info-nama">xxx.xxx.xxx</span></h6>
</div>
<div class="col-2">
</div>
<div class="col-10">
<h6>Tipe Produk : <span id="info-produk">xxx.xxx.xxx</span></h6>
</div>
<div class="col-2">
</div>
<div class="col-10">
<h6>Saldo : <span id="info-saldo">xxx.xxx.xxx</span></h6>
</div>
</div>
<div class="row">
<div class="col-2">
<label class="label-required" for="">Tanggal Autodebet</label>
</div>
<div class="col-10">
<select name="scheduled_day" id="scheduled_day" class="select2 form-control scheduled_day">
<option disabled value="{{ $data->scheduled_day }}">{{ $data->scheduled_day }}</option>
#for ($i = 1; $i <= 31; $i++)
<option class="day_option" id="day_{{ $i }}" value="{{ $i }}">{{ $i }}</option>
#endfor
</select>
</div>
</div>
<div class="row">
<div class="col-2">
<label for="saving_type_package">Keterangan</label>
</div>
<div class="col-10">
<textarea name="desc" class="form-control desc" id="" cols="30" rows="5">{{ $data->desc }}</textarea>
</div>
</div>
<div class="row">
<div class="col-2">
<label class="label-required" for="" >Status Autodebet</label>
</div>
<div class="col-10">
<input type="hidden" id="transaction_schedule_status" name="transaction_schedule_status" value="{{ $data->transaction_schedule_status ?? 1 }}">
<div class="az-toggle {{ isset($data->transaction_schedule_status) ? ($data->transaction_schedule_status == 1 ? 'on' :'') : 'on' }}" id="autodebet_status_toggle"><span></span></div>
</div>
</div>
<input type="hidden" value="" id="origin_id" name="origin_id">
<input type="hidden" class="schedule_id" id="schedule_id" name="schedule_id">
<input type="hidden" name="destination_code" id="destination_code_input">
<input type="hidden" name="origin_code" id="origin_code_input">
<div class="row">
<div class="col-12">
<div class="float-right">
<div class="btn-group">
<a href="{{admin_url('cb/tabungan/jadwal-autodebet')}}">
<button id="back_button" type="button" class="btn btn-secondary btn-block"><i class="typcn typcn-times"></i>Batalkan</button>
</a>
</div>
<div class="btn-group">
<button id="submit_button" class="btn btn-success btn-block">
<i id="loading_icon" style="display: none" class="fa fa-spin fa-spinner"></i>
<i id="submit_icon" class="typcn typcn-input-checked"></i>
Simpan</button>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</form>
how i fixed this problem?

Show data based on modal click

I made a while loop for the data to be displayed in a table format, I prepared <a> when clicked it opens a modal.
I want to have each modal have more info on that specific data when clicked.
Here is how I prepared things:
<?php
$mysqli = new mysqli('localhost', 'mushref', 'Almadina1!', 'security_db')
or die('Dramatic Error: ' . mysqli_error($mysqli));
$selectquery = "SELECT * FROM cases_reports";
$query = mysqli_query($mysqli, $selectquery);
$nums = mysqli_num_rows($query);
while($res = mysqli_fetch_array($query)) {
?>
<tr>
<td class="name mb-0 text-sm"> <?php echo $res['cccEmployee']?> </td>
<td> <?php echo $res['irNumber']?> </td>
<td> <?php echo $res['caseType']?> </td>
<td> <?php echo $res['startDateTime']?> </td>
<td> <?php echo $res['endDateTime']?> </td>
<td>
<div class="dropdown">
<a class="btn btn-sm btn-icon-only text-light" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item" href="#">Print PDF</a>
<a class="dropdown-item" href="#">Export Excel</a>
<a class="dropdown-item" href="#">Export Access</a>
</div>
</div>
</td>
</tr>
<div class="modal fade" id="modal-default" tabindex="-1" role="dialog" aria-labelledby="modal-default" aria-hidden="true">
<div class="modal-dialog modal- modal-dialog-centered modal-" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="modal-title-default"> <?php echo $res['caseType']?> </h6>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php
echo $res['caseType'];
?>
</div>
</div>
<?php }?> <!-- End php While -->
Of course, the modal shows the first data available, which in this case "accident". How can I show each data's info when the modal URL is clicked?
just call your modal programmatically from js and load/replace its corresponing data before showing modal.
<?php echo $res['caseType']?>
and in your js file :
$(document).ready(function(){
$("#modalLuncher").click(function(){
$("#modal-title-default").html('read from #modalLuncher data-* tag');
// $("#other-replacements") ;
$("#modal-default").modal();
});
});
I wanted to show the modal so I can Ajax edit the table.
Here what I did:
Script:
$(document).ready(function() {
// Append values in input fields
$(document).on('click', 'a[data-role=update]', function(){
var id = $(this).data('id');
var cccEmployee = $("#"+id).children('td[data-target=cccEmployee]').text();
var irNumber = $("#"+id).children('td[data-target=irNumber]').text();
var caseType = $("#"+id).children('td[data-target=caseType]').text();
var startDateTime = $("#"+id).children('td[data-target=startDateTime]').text();
var endDateTime = $("#"+id).children('td[data-target=endDateTime]').text();
//Append the variables
$('#cccEmployee').val(cccEmployee);
$('#IR_number').val(irNumber);
$('#case_type').val(caseType);
$('#startDate').val(startDateTime);
$('#endDate').val(endDateTime);
$('#caseId').val(id);
$('#reportsModal').modal('toggle');
});
//Create event to get data from fields and update.
$('#save_report_changes').click(function() {
var id = $('#caseId').val();
var cccEmployee = $('#cccEmployee').val();
var irNumber= $('#IR_number').val();
var caseType = $('#case_type').val();
var startDateTime = $('#startDate').val();
var endDateTime = $('#endDate').val();
$.ajax({
url: '/edit-report',
method: 'post',
data: {
id: id,
cccEmployee: cccEmployee,
irNumber: irNumber,
caseType: caseType,
startDateTime: startDateTime,
endDateTime: endDateTime
},
success: function(response) {
$("#"+id).children('td[data-target=cccEmployee]').text(cccEmployee);
$("#"+id).children('td[data-target=irNumber]').text(irNumber);
$("#"+id).children('td[data-target=caseType]').text(caseType);
$("#"+id).children('td[data-target=startDateTime]').text(startDateTime);
$("#"+id).children('td[data-target=endDateTime]').text(endDateTime);
$('#reportsModal').modal('toggle');
},
});
});
});
Then created a while loop in php to display the data + linking the edit button to the ajax:
<!-- Start PHP While -->
<?php
$mysqli = new mysqli('localhost', 'mushref', 'Almadina1!', 'security_db')
or die('Dramatic Error: ' . mysqli_error($mysqli));
if( isset($_POST['id']) ) {
$id = $_POST['id'];
$ccc_employee = $_POST['cccEmployee'];
$IR_number = $_POST['irNumber'];
$case_type = $_POST['caseType'];
$caseLocation = $_POST['caseLocation'];
$startDate = $_POST['startDateTime'];
$endDate = $_POST['endDateTime'];
$case_description = $_POST['caseDesc'];
$action_taken = $_POST['actionsTaken'];
$details = $_POST['caseDetails'];
$notes = $_POST['caseNotes'];
$recommendation = $_POST['caseRecommendation'];
// Query to update data
$result = mysqli_query($mysqli, "UPDATE cases_reports SET
cccEmployee='$ccc_employee',
irNumber='$IR_number',
caseType='$case_type',
caseLocation='$caseLocation',
startDateTime='$startDate',
endDateTime='$endDate',
caseDesc='$case_description',
actionsTaken='$action_taken',
caseDetails='$details',
caseNotes='$notes',
caseRecommendation='$recommendation'
WHERE id='$id'");
if( $result ) {
return "Data updated successfully";
}
}
$selectquery = "SELECT * FROM cases_reports";
$table = mysqli_query($mysqli, $selectquery);
$nums = mysqli_num_rows($table);
while($res = mysqli_fetch_array($table)) {
?>
<tr id="<?php echo $res['id']?>">
<td data-target="cccEmployee"> <?php echo $res['cccEmployee']?> </td>
<td data-target="irNumber"> <?php echo $res['irNumber']?> </td>
<td data-target="caseType"> <?php echo $res['caseType']?> </td>
<td data-target="startDateTime"> <?php echo $res['startDateTime']?> </td>
<td data-target="endtDateTime"> <?php echo $res['endDateTime']?> </td>
<td class="table-actions">
<a href="#" data-role="update" data-id="<?php echo $res['id']; ?>">
<i class="fas fa-edit"></i>
</a>
<!-- <a href="#!" class="table-action table-action-delete" data-toggle="tooltip" data-original-title="Delete product">
<i class="fas fa-trash"></i>
</a> -->
</td>
<td>
<div class="dropdown">
<a class="btn btn-sm btn-icon-only text-light" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item" href="#">Print PDF</a>
<a class="dropdown-item" href="#">Export Excel</a>
<a class="dropdown-item" href="#">Export Access</a>
</div>
</div>
</td>
</tr>
<div class="modal fade" id="reportsModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal- modal-dialog-centered modal-" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="modal-title-default"> Case Details </h6>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="case-data">
<div class="form-row">
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="cccEmployee">CCC Employee</label>
<input type="text" class="form-control" id="cccEmployee" name="cccEmployee">
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="IR_number">IR Number</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="IR_number">IR#</span>
</div>
<input type="number" class="form-control" name="IR_number" id="IR_number">
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="case_type">Case Type</label>
<select class="form-control" name="case_type" id="case_type" data-toggle="select">
<option value="" disabled selected>Select Case Type</option>
<option value="Accident">Accident</option>
<option value="Theft">Theft</option>
<option value="Death">Death</option>
<option value="Harrasment">Harrasment</option>
<option value="badBehaviour">Bad Behaviour</option>
<option value="Drugs">Drugs</option>
<option value="Drunk">Drunk</option>
<option value="Fight">Fight</option>
<option value="Medical">Medical</option>
<option value="illegalEntry">Illegal Entry</option>
<option value="illegalWorker">Illegal Worker</option>
<option value="Fire">Fire</option>
<option value="Electric">Electric</option>
<option value="illegalHunting">Illegal Hunting</option>
<option value="oilLeak">Oil Leak</option>
<option value="petrolLeak">Petrol Leak</option>
<option value="Kidnapping">Kidnapping</option>
<option value="Blackmail">Blackmail</option>
<option value="Misunderstanding">Misunderstanding</option>
<option value="propertyDamage">Property Damage</option>
<option value="smoke_NoFire">Smoke, No Fire</option>
<option value="stuck_InElevator">Stuck in Elevator</option>
<option value="Scooter">Scooter</option>
<option value="Drifting">Drifting</option>
<option value="LostPerson">Lost Person</option>
<option value="Fraud_Forgery">Fraud/Forgery</option>
<option value="Other">Other</option>
</select>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="caseLocation">Location</label>
<select class="form-control" name="caseLocation" id="caseLocation" data-toggle="select">
<option value="" disabled selected>Select Location</option>
<option value="Baylasun">Baylasun</option>
<option value="Baylasun Hotel">Baylasun Hotel</option>
<option value="AL-Waha">AL-Waha</option>
<option value="Al-Morooj">Al-Morooj</option>
<option value="Royal Green">Royal Green</option>
<option value="Beach Towers">Beach Towers</option>
<option value="Emmar Building">Emmar Building</option>
<option value="Industrial Area (East)">Industrial Area (East)</option>
<option value="Industrial Area (West)">Industrial Area (West)</option>
<option value="Hejaz Gate">Hejaz Gate</option>
<option value="Gate 3">Gate 3</option>
<option value="Marina 1">Marina 1</option>
<option value="Marina 2">Marina 2</option>
<option value="Marina 3">Marina 3</option>
<option value="Tala Garden">Tala Garden</option>
<option value="AL-Shorooq">AL-Shorooq</option>
<option value="Yam Beach">Yam Beach</option>
<option value="Sales Center">Sales Center</option>
</select>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="startDate">Start Date & Time</label>
<input class="form-control" type="datetime-local" name="startDate" id="startDate">
</div>
</div>
<div class="col-md-6 mb-3">
<div class="form-group">
<label class="form-control-label" for="endDate">End Date & Time</label>
<input class="form-control" type="datetime-local" name="endDate" id="endDate">
</div>
</div>
<div class="col-md-12 mb-3">
<div class="form-group">
<label class="form-control-label" for="case_description">Case Description</label>
<textarea class="form-control" name="case_description" id="case_description" rows="3"></textarea>
</div>
</div>
<div class="col-md-12 mb-3">
<div class="form-group">
<label class="form-control-label" for="action_taken">Actions Taken</label>
<textarea class="form-control" name="action_taken" id="action_taken"></textarea>
</div>
</div>
<div class="col-md-12 mb-3">
<div class="form-group">
<label class="form-control-label" for="details">Details</label>
<textarea class="form-control" name="details" id="details"></textarea>
</div>
</div>
<div class="col-md-12 mb-3">
<div class="form-group">
<label class="form-control-label" for="notes">Notes</label>
<textarea name="notes" id="notes" class="form-control"></textarea>
</div>
</div>
<div class="col-md-12 mb-3">
<div class="form-group">
<label class="form-control-label" for="recommendation">Recommendations</label>
<textarea name="recommendation" id="recommendation" class="form-control"></textarea>
</div>
</div>
<input type="hidden" id="caseId" class="form-control"/>
</div>
</div>
<div class="modal-footer">
<button type="button" id="save_report_changes" class="btn btn-primary">Save changes</button>
</div>
<?php } //End php While

Laravel Crop Image Before Upload

I'm new to Jquery. I'm building a project with Laravel 7.28. I want users to crop an image before upload. I've searched on the net but all examples upload the image right after cropping. But I want the user to crop but not upload. I want users to upload the cropped image with input fields. Here is my form and script code:
#section('content')
<div class="row">
<div class="col-lg-12 col-12">
<!-- Basic Forms -->
<div class="box">
<div class="box-header with-border">
<h4 class="box-title">Quick Offer Creation</h4>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="card-text">
#if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
</div>
{!! Form::open(['route'=>['quick_offer.store'], 'method' => 'POST', 'class'=> 'form', 'files' => true ]) !!}
<div class="row">
<div class="col-6">
<div class="form-group row col-md-12">
<label for="project_id" class="col-sm-2 col-form-label">Project</label>
<div class="col-sm-10">
<select name="project_id" id="" class="form-control select2">
<option value="">Please Select</option>
#foreach($projects as $project)
<option
value="{{ $project->id }}" {{ old('project_id') == $project->id ? 'selected' : '' }}>{{ $project->code . ', ' . $project->title}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group row col-md-12">
<label for="bedroom" class="col-sm-2 col-form-label">Bedroom</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="bedroom" name="bedroom"
value="{{ old('bedroom') }}" min="1">
</div>
</div>
<div class="form-group row col-md-12">
<label for="location" class="col-sm-2 col-form-label">Location</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="location" name="location"
value="{{ old('location') }}">
</div>
</div>
<div class="form-group row col-md-12">
<label for="status" class="col-sm-2 col-md-2 col-form-label">Status</label>
<div class="col-sm-10 col-md-10">
<select name="status" id="" class="form-control">
<option value="">Please Select</option>
<option value="publish" {{ old('status') == 'publish' ? 'selected' : '' }}>
Publish
</option>
<option value="draft" {{ old('status') == 'draft' ? 'selected' : '' }}>
Draft
</option>
<option value="review" {{ old('status') == 'review' ? 'selected' : '' }}>
Review
</option>
<option value="unpublish" {{ old('status') == 'unpublish' ? 'selected' : '' }}>
Unpublish
</option>
</select>
</div>
</div>
<div class="form-group row col-md-12">
<label for="photo" class="col-sm-2 col-form-label">
Image
<br>
<small>The photo must be square</small>
</label>
<div class="col-sm-10">
<input type="file" name="photo" class="image form-control" value="{{ old('photo') }}">
</div>
</div>
</div>
<div class="col-6">
<div class="form-group row col-md-12">
<label for="currency" class="col-sm-2 col-md-2 col-form-label">Currency</label>
<div class="col-sm-10 col-md-10">
<select name="currency" id="" class="form-control">
<option value="">Please Select</option>
<option value="TRY" {{ old('currency') == 'TRY' ? 'selected' : '' }}>
(₺) Turkish Lira
</option>
<option value="EUR" {{ old('currency') == 'EUR' ? 'selected' : '' }}>
(€) Euro
</option>
<option value="USD" {{ old('currency') == 'USD' ? 'selected' : '' }}>
($) American Dollar
</option>
<option value="GBP" {{ old('currency') == 'GBP' ? 'selected' : '' }}>
(£) GBP
</option>
</select>
</div>
</div>
<div class="form-group row col-md-12">
<label for="price" class="col-sm-2 col-form-label">Normal Price</label>
<div class="col-sm-10">
<input class="form-control" type="number" id="price" name="price"
min="0" value="{{ old('price') }}">
</div>
</div>
<div class="form-group row col-md-12">
<label for="discounted_price" class="col-sm-2 col-form-label">Discounted Price</label>
<div class="col-sm-10">
<input class="form-control" type="number" id="discounted_price"
name="discounted_price"
min="0" value="{{ old('discounted_price') }}">
</div>
</div>
<div class="form-group row col-md-12">
<label for="button_link" class="col-sm-2 col-form-label">Call to Action Link</label>
<div class="col-sm-10">
<input class="form-control" type="url" id="button_link" name="button_link"
value="{{ old('button_link') }}">
</div>
</div>
<div class="form-group row col-md-12">
<label for="company" class="col-sm-2 col-md-2 col-form-label">Company</label>
<div class="col-sm-10 col-md-10">
<select name="company" id="" class="form-control">
<option value="">Please Select</option>
<option
value="londonist_investments" {{ old('company') == 'londonist_investments' ? 'selected' : '' }}>
Londonist Investments
</option>
<option value="turyap_uk" {{ old('company') == 'turyap_uk' ? 'selected' : '' }}>
Turyap UK
</option>
</select>
</div>
</div>
</div>
<div class="col-12">
<div class="form-group row col-md-12">
<label for="key_points" class="col-md-2 col-form-label">Key Points</label>
<div class="col-md-12">
<textarea class="textarea" placeholder="One to each line"
name="key_points" id="key_points"
style="width: 100%; min-height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;">{{ old('key_points')}}</textarea>
</div>
</div>
</div>
<div class="col-12">
<div class="form-actions">
<button type="submit" class="btn btn-danger btn-lg">
<i class="fa fa-check-square-o"></i> Save
</button>
</div>
</div>
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalLabel">Laravel Cropper Js - Crop Image Before
Upload - Tutsmake.com</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="img-container">
<div class="row">
<div class="col-md-8">
<img id="image"
src="https://avatars0.githubusercontent.com/u/3456749">
</div>
<div class="col-md-4">
<div class="preview"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel
</button>
<button type="button" class="btn btn-primary" id="crop">Crop</button>
</div>
</div>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
{!! Form::close() !!}
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
</div>
#endsection
#section('js')
<script>
var $modal = $('#modal');
var image = document.getElementById('image');
var cropper;
$("body").on("change", ".image", function(e){
var files = e.target.files;
var done = function (url) {
image.src = url;
$modal.modal('show');
};
var reader;
var file;
var url;
if (files && files.length > 0) {
file = files[0];
if (URL) {
done(URL.createObjectURL(file));
} else if (FileReader) {
reader = new FileReader();
reader.onload = function (e) {
done(reader.result);
};
reader.readAsDataURL(file);
}
}
});
$modal.on('shown.bs.modal', function () {
cropper = new Cropper(image, {
aspectRatio: 1,
viewMode: 3,
preview: '.preview'
});
}).on('hidden.bs.modal', function () {
cropper.destroy();
cropper = null;
});
$("#crop").click(function(){
canvas = cropper.getCroppedCanvas({
width: 800,
height: 800,
});
canvas.toBlob(function(blob) {
url = URL.createObjectURL(blob);
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function() {
var base64data = reader.result;
$.ajax({
type: "POST",
dataType: "json",
url: "crop-image-upload",
data: {'_token': $('meta[name="_token"]').attr('content'), 'image': base64data},
success: function(data){
console.log(data);
$modal.modal('hide');
alert("Crop image successfully uploaded");
}
});
}
});
})
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.js"></script>
How can I do that?
Better to do resizing in controller, using intervention/image
Package Link
Tutorial Link
Hope this will be useful.

Post option value to mysql via ajax wont work

i have been working on some project and getting some experience on php and ajax, jquery. So i have checked 20+ question on stackoverflow but couldnt find the solution even if its already answered the same question.
I have tryed 10 diffrent solution but i guess im skipping something.
I have simple select box and im using ajax to send mysql but only select box doesnt work for some reason.
HTML Code:
<section class="resume-section p-3 p-lg-5 d-flex flex-column" id="rezervasyon">
<div class="my-auto">
<h2 class="mb-5">Online Rezervasyon</h2>
<form id="loginForm" method="" action="" novalidate="novalidate">
<div class="form-group row">
<label for="rez_ad" class="col-sm-2 col-form-label">İsim Soyisim</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="rez_ad" id="rez_ad" placeholder="İsim Soyisim">
</div>
</div>
<div class="form-group row">
<label for="rez_saat" class="col-sm-2 col-form-label">Rezervasyon Saati</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="rez_saat" id="rez_saat" placeholder="Rezervasyon saati">
</div>
</div>
<div class="form-group row">
<label for="rez_gsm" class="col-sm-2 col-form-label">Cep Numaranız</label>
<div class="col-sm-10">
<input type="number" class="form-control" name="rez_gsm" id="rez_gsm" placeholder="İletişim numaranız.">
</div>
</div>
<div class="form-group row">
<label for="rez_tarih" class="col-sm-2 col-form-label">Tarih</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="rez_tarih" id="rez_tarih" placeholder="Tarih belirtiniz.">
</div>
</div>
<div class="form-group row">
<label for="rez_email" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="rez_email" id="rez_email" placeholder="Email">
</div>
</div>
<div class="form-group row">
<label for="rez_tip" class="col-sm-2 col-form-label" name="rez_tip" id="rez_tip">Rezervasyon Tipi</label>
<div class="col-sm-10">
<select id="rez_tip" class="custom-select">
<option value="" selected>Rezervasyon Tipi Seçiniz</option>
<option value="1">Cuma Fix Menü</option>
<option value="2">Cumartesi Fix Menü</option>
<option value="3">Haftaiçi ALKOLSÜZ</option>
<option value="4">Haftaiçi ALKOLLÜ</option>
<option value="5">Kutlama / Doğum Günü</option>
<option value="6">Diğer</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="rez_sayi" class="col-sm-2 col-form-label" id="rez_sayi" name="rez_sayi">Kişi Sayısı</label>
<div class="col-sm-10">
<select id="rez_sayi" class="custom-select">
<option value="" selected>Kişi Sayısı Belirtiniz</option>
<option value="1">2 Kişilik Rezervasyon</option>
<option value="2">4 Kişilik Rezervasyon</option>
<option value="3">4+ Kişilik Rezervasyon</option>
<option value="4">6+ Kişilik Rezervasyon</option>
<option value="5">8+ Kişilik Rezervasyon</option>
<option value="6">20+ Kişilik Rezervasyon</option>
</select>
</div>
</div>
<textarea name="rez_aciklama" id="rez_aciklama" class="form-control" rows="6" cols="21" required="required"
placeholder="Ek açıklama girebilirsiniz."></textarea>
<form class="was-validated">
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title text-center" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="divider"></div>
<div class="right-side">
<button type="button" class="btn btn-danger btn-link">Delete</button>
</div>
</div>
</div>
</div>
</div>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="customControlValidation1" required>
<label class="custom-control-label" for="customControlValidation1">Rezervasyon Şartlarını Kabul Ediyorum!</label>
<div class="invalid-feedback">Rezervasyon şartlarını okuyunuz!</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="button" class="btn btn-success" name="insert-data" id="insert-data" onclick="insertData()">Rezervasyonu Tamamla</button>
</div>
</div>
<br>
<p id="message"></p>
</form>
Here is my php file ;
<?php
include('db.php');
$rez_ad=$_POST['rez_ad'];
$rez_saat=$_POST['rez_saat'];
$rez_gsm=$_POST['rez_gsm'];
$rez_tarih=$_POST['rez_tarih'];
$rez_tip=$_POST['rez_tip'];
$rez_sayi=$_POST['rez_sayi'];
$rez_aciklama=$_POST['rez_aciklama'];
$stmt = $DBcon->prepare("INSERT INTO student(rez_ad,rez_saat,rez_gsm,rez_tarih,rez_tip,rez_sayi,rez_aciklama) VALUES(:rez_ad, :rez_saat,:rez_gsm,:rez_tarih,:rez_tip,:rez_sayi,:rez_aciklama)");
$stmt->bindparam(':rez_ad', $rez_ad);
$stmt->bindparam(':rez_saat', $rez_saat);
$stmt->bindparam(':rez_gsm', $rez_gsm);
$stmt->bindparam(':rez_tarih', $rez_tarih);
$stmt->bindparam(':rez_tip', $rez_tip);
$stmt->bindparam(':rez_sayi', $rez_sayi);
$stmt->bindparam(':rez_aciklama', $rez_aciklama);
if($stmt->execute())
{
$res="Data Inserted Successfully:";
echo json_encode($res);
}
else {
$error="Not Inserted,Some Probelm occur.";
echo json_encode($error);
}
?>
Here is my jquery code;
function insertData() {
var rez_ad=$("#rez_ad").val();
var rez_saat=$("#rez_saat").val();
var rez_gsm=$("#rez_gsm").val();
var rez_tarih=$("#rez_tarih").val();
var rez_tip=$("#rez_tip").val();
var rez_sayi=$("#rez_sayi").val();
var rez_aciklama=$("#rez_aciklama").val();
// AJAX code to send data to php file.
$.ajax({
type: "POST",
url: "rez/insert-data.php",
data: {rez_ad:rez_ad,rez_saat:rez_saat,rez_gsm:rez_gsm,rez_tarih:rez_tarih,rez_tip:rez_tip,rez_sayi:rez_sayi,rez_aciklama:rez_aciklama},
dataType: "JSON",
success: function(data) {
$("#message").html(data);
$("p").addClass("alert alert-success");
},
error: function(err) {
alert(err);
}
});
}
Thanks for help !
You should then pass the rez_tip option in ajax call also.
<script type="text/javascript">
function insertData() {
//var rez_tip=$("#rez_tip option:selected").text();
//var rez_sayi=$("#rez_sayi option:selected").text();
var rez_tip=$("select#rez_tip").val();
var rez_sayi=$("select#rez_sayi").val();
// AJAX code to send data to php file.
$.ajax({
type: "POST",
url: "rez/insert-data.php",
data: {rez_sayi:rez_sayi,rez_tip:rez_tip},
dataType: "JSON",
success: function(data) {
$("#message").html(data);
$("p").addClass("alert alert-success");
},
error: function(err) {
alert(err);
}
});
}
</script>

How to submit a jQuery step form

hope all is well. I really really really do need help submitting a jQuery step wizard form. I did get a plugin to help but it does most of its functionalities in jQuery and not html.
At the moment i have:
- Created the database and necessary table
- Created html form using jquery steps
- Connected the form to the database
- Connected database to html table for display
This is my html code:
<div class="modal fade" id="pat_add_modal" tabindex="-1" role="dialog" aria-labelledby="add_patient_label">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="add_patient_label">Add New Patient</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<!-- PHP Form Processor -->
<?php
include 'db.php';
if(isset($_POST['submit'])){
$pat_sname = $_POST['pat_sname'];
$pat_fname = $_POST['pat_fname'];
$pat_gender = $_POST['pat_gender'];
$pat_dob = $_POST['pat_dob'];
$pat_phone = $_POST['pat_phone'];
$pat_email = $_POST['pat_email'];
$insurance_companies = $_POST['insurance_companies'];
$card_no = $_POST['card_no'];
$pat_allergies = $_POST['pat_allergies'];
$pat_history = $_POST['pat_history'];
$pat_address = $_POST['pat_address'];
$nok_name = $_POST['nok_name'];
$nok_phone = $_POST['nok_phone'];
$nok_email = $_POST['nok_email'];
$pat_dependants = $_POST['pat_dependants'];
$pat_work = $_POST['pat_work'];
$pat_work_address = $_POST['pat_work_address'];
$work_phone = $_POST['work_phone'];
$work_email = $_POST['work_email'];
$ins_sql = "INSERT INTO patients (surname, first_name, gender, dateofbirth, phone, email, insurance_co, insurance_card_no, allergies, medical_history, full_address, nok_name, nok_phone, nok_email, dependants, palce_of_work, work_full_address, work_phone, work_email) VALUES ('$pat_sname', '$pat_fname', '$pat_gender', '$pat_dob', '$pat_phone', '$pat_email', '$insurance_companies', '$card_no', '$pat_allergies', '$pat_history', '$pat_address', '$nok_name', '$nok_phone', '$nok_email', '$pat_dependants', '$pat_work', '$pat_work_address', '$work_phone', '$work_email')";
$run_sql = mysqli_query($conn, $ins_sql);
echo "insertion success";
}else{
echo "insertion failed";
}
?>
<div class="card-block wizard-content">
<form class="tab-wizard wizard-circle form-horizontal floating-labels" role="form" name"this" id"this" action="patients.php" method="post">
<!-- Step 1 -->
<h6><strong>Personal Info</strong></h6>
<section>
<div class="row">
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="pat_sname" id="pat_sname" required><span class="bar"></span><label for="pat_sname">Surname :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="pat_fname" id="pat_fname" required><span class="bar"></span><label for="pat_fname">First Name :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<select class="form-control p-0" name="pat_gender" id="pat_gender" required>
<option value=""></option>
<option value="M">Male</option>
<option value="F">Female</option>
</select><span class="bar"></span>
<label for="pat_gender">Gender :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="date" class="form-control" name="pat_dob" id="pat_dob" required><span class="bar"></span><label for="pat_dob">D.O.B :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="tel" class="form-control" name="pat_phone" id="pat_phone" required><span class="bar"></span><label for="pat_phone">Phone :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="email" class="form-control" name="pat_email" id="pat_email" required><span class="bar"></span><label for="pat_email">Email :</label>
</div>
</div>
</div>
</section>
<!-- Step 2 -->
<h6><strong>Health Info</strong></h6>
<section>
<div class="row">
<div class="col-md-6">
<div class="form-group m-t-20">
<select class="form-control p-0" name="insurance_companies" id="insurance_companies" required>
<option value=""></option>
<option value="AAR">AAR</option>
<option value="AIG">AIG</option>
<option value="Britam">Britam</option>
<option value="IAA">IAA</option>
<option value="ICEA">ICEA</option>
<option value="Goldstar">Goldstar</option>
<option value="Liberty">Liberty</option>
<option value="NIC">NIC</option>
<option value="Sanlam">Sanlam</option>
<option value="SWICO">SWICO</option>
<option value="UAP">UAP</option>
</select><span class="bar"></span>
<label for="insurance_companies">Insurance Co.</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="card_no" id="card_no" required><span class="bar"></span><label for="card_no">Insurance Card No.</label>
</div>
</div>
<div class="col-md-12">
<div class="form-group m-t-20">
<textarea class="form-control" rows="1" id="pat_allergies" required></textarea>
<span class="bar"></span>
<label for="pat_allergies">Allergies :</label>
</div>
</div>
<div class="col-md-12">
<div class="form-group m-t-20">
<textarea class="form-control" rows="1" id="pat_history" required></textarea>
<span class="bar"></span>
<label for="pat_history">Medical History :</label>
</div>
</div>
</div>
</section>
<!-- Step 3 -->
<h6><strong>Home Info</strong></h6>
<section>
<div class="row">
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="pat_address" id="pat_address" required><span class="bar"></span><label for="pat_address">Full Address :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="nok_name" id="nok_name" required><span class="bar"></span><label for="nok_name">Next of Kin :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="tel" class="form-control" name="nok_phone" id="nok_phone" required><span class="bar"></span><label for="nok_phone">Phone :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="email" class="form-control" name="nok_email" id="nok_email" required><span class="bar"></span><label for="nok_email">Email :</label>
</div>
</div>
<div class="col-md-12">
<div class="form-group m-t-20">
<textarea class="form-control" rows="1" id="pat_dependants" required></textarea>
<span class="bar"></span>
<label for="pat_dependants">Dependants :</label>
</div>
</div>
</div>
</section>
<!-- Step 4 -->
<h6><strong>Work Info</strong></h6>
<section>
<div class="row">
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="pat_work" id="pat_work" required><span class="bar"></span><label for="pat_work">Place of Work :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="text" class="form-control" name="pat_work_address" id="pat_work_address" required><span class="bar"></span><label for="pat_work_address">Full Address :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="tel" class="form-control" name="work_phone" id="work_phone" required><span class="bar"></span><label for="work_phone">Phone :</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group m-t-20">
<input type="email" class="form-control" name="work_email" id="work_email" required><span class="bar"></span><label for="work_email">Email :</label>
</div>
</div>
</div>
</section>
</form>
</div>
</div>
</div>
</div>
</div>
and this my script:
$(".tab-wizard").steps({
headerTag: "h6"
, bodyTag: "section"
, transitionEffect: "fade"
, titleTemplate: '<span class="step">#index#</span> #title#'
, labels: {
finish: 'Finish'
},
onFinished: function (event, currentIndex) {
swal({
type: "success",
title: "Good Job!",
text: "You have successfully added a new patient.",
});
var form = $(this);
form.submit();
},
});
Below is my html table:
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-block">
<div class="table-responsive">
<!--<div class="col-md-12 align-self-center">
<button class="btn pull-right hidden-sm-down btn-danger m-l-5" id="deletebutton" type="button" data-toggle="modal" data-target="#adddoctormodal" data-original-title="View" data-whatever="#mdo"><i class="mdi mdi-delete"></i></button></a>
<button class="btn pull-right hidden-sm-down btn-info m-l-5" type="button" data-toggle="modal" data-target="#adddoctormodal" data-original-title="View" data-whatever="#mdo"><i class="mdi mdi-pen"></i></button></a>
<button class="btn pull-right hidden-sm-down btn-warning m-l-5" type="button" data-toggle="modal" data-target="#doc_view_modal" data-original-title="View" data-whatever="#mdo"><i class="mdi mdi-information-outline"></i></button></a>
<button class="btn pull-right hidden-sm-down btn-primary m-l-5" type="button" data-toggle="modal" data-target="#adddoctormodal" data-original-title="View" data-whatever="#mdo"><i class="mdi mdi-cash-multiple"></i></button></a>
<button class="btn pull-right hidden-sm-down btn-success m-l-20" type="button" data-toggle="modal" data-target="#adddoctormodal" data-original-title="View" data-whatever="#mdo"><i class="mdi mdi-calendar-plus"></i></button></a>
</div> -->
<table id="patientstable" class="display nowrap table table-hover table-striped table-bordered m-t-20" width="100%" cellspacing="0">
<thead>
<tr>
<th class="text-center">ID</th>
<th>Surname</th>
<th>First Name</th>
<th class="text-center">D.O.B</th>
<th class="text-center" >Gender</th>
<th class="text-center">Phone</th>
<th style="width: 100px;"></th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM patients";
$run_sql = mysqli_query($conn,$sql);
while ($rows = mysqli_fetch_array($run_sql)){
echo '
<tr>
<td class="text-center">'.$rows['id'].'</td>
<td>'.$rows['first_name'].'</td>
<td>'.$rows['surname'].'</td>
<td class="text-center">'.$rows['dateofbirth'].'</td>
<td class="text-center">'.$rows['gender'].'</td>
<td class="text-center">'.$rows['phone'].'</td>
<td id="actionicons">
<a href="user_id='.$rows['id'].'" data-toggle="modal" data-target="#pat_view_modal"> <i class="mdi mdi-information-outline text-warning"></i>
</i>
<a href="#" data-toggle="tooltip" data-original-title="Delete"> <i class="mdi mdi-delete text-danger"></i>
</td>
</tr>
';}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
I am stuck at a point where now have to submit the form but i am unable to since i can't call/reference the finish submit using an name or id since i can't assign it one.
Please help. Thanks.
Brian Dx.
In your patients.php you can use:
if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
instead of:
if(isset($_POST['submit']))
since you can't put a submit name in jquery steps.

Categories