I am using gentellela template which is having a data table id to datatable.
Now im doing modal popup of table and include it into one page which is having a button to call all those modals.
My problem is when 2 modals have table id to datatable. the other datatable seems broken. All i want is to have those datatable working properly.
this is my first modal.
<div class="modal fade" id="USERSVIEW" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" >
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>View Users</h2>
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
<div class="clearfix"></div>
</div>
<div class="x_content">
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap dataTable" cellspacing="0" width="100%">
<thead>
<tr>
<th style="text-align: center;"> Branch Code </th>
<th style="text-align: center;"> Branch Name </th>
<th style="text-align: center;"> Branch Address </th>
<th style="text-align: center;"> Branch Admin Name </th>
<th style="text-align: center;"> Status </th>
</tr>
</thead>
<tbody>
<?php include 'includes/dashboarduserfetch.php';?>
</tbody>
</table>
<div class="ln_solid"></div>
<button class="btn btn-danger" class="close" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
And this is my second modal.
<div class="modal fade" id="TASKSVIEW" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" >
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>View Tasks</h2>
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
<div class="clearfix"></div>
</div>
<div class="x_content">
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap dataTable" cellspacing="0" width="100%">
<thead>
<tr>
<th style="text-align: center;"> Branch Code </th>
<th style="text-align: center;"> Task Code </th>
<th style="text-align: center;"> Task Name </th>
<th style="text-align: center;"> Task Description </th>
<th style="text-align: center;"> Expiry Date </th>
<th style="text-align: center;"> Status </th>
</tr>
</thead>
<tbody>
<?php include 'includes/dashboardtaskfetch.php';?>
</tbody>
</table>
<div class="ln_solid"></div>
<button class="btn btn-danger" class="close" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
i want to call the same modal in other page which is having these buttons to call modal.
<button class="btn btn-primary" data-toggle="modal" data-target="#USERSVIEW" style="width:90%; margin-left:5%; margin-top:-3%;">View Users Created</button>
<button class="btn btn-primary" data-toggle="modal" data-target="#TASKSVIEW" style="width:90%; margin-left:5%; margin-top:-3%;">View Tasks Created</button>
Id attribute should be unique for each element so just change the id to datatable1 and datatable2
1st : For table 1 id should be datatable1 .
Html :
<table id="datatable1" class="table table-striped table-bordered dt-responsive nowrap dataTable" cellspacing="0" width="100%">
Script:
$('#datatable1').dataTable({ .... });
2nd : For table 2 id should be datatable2 .
Html :
<table id="datatable2" class="table table-striped table-bordered dt-responsive nowrap dataTable" cellspacing="0" width="100%">
Script:
$('#datatable2').dataTable({ .... });
The id attribute should be unique in your example will match the first id in the page
Use class if all table has the same dataTable options
Change the id="datatable" to class="datatable" or add datatable to class attribute
And call
$('.datatable').dataTable();
If you have different options change for each table just change id for each. id="datatable1" , id="datatable1"
And call like
$('#datatable1').dataTable({});
$('#datatable2').dataTable({});
Related
i am having a problem on showing all the data in a modal which triggering by the id. the situation right now is that whenever i clicked the detail button, the modal is only show 1 row of data.
please do help me on how im gonna handle this kind of problem to show all the data from the tbl_rekomendasi_pit on the modal whenever i click the detail button from the table which show the data from the tbl_kegiatan_pit
thank you in advance!
the tables;
tbl_kegiatan_pit
id_kegiatan
kegiatan
judul
1
kesehatan
Kajian Aktual Potensi dan Pemanfaatan Tumbuhan Obat
tbl_rekomendasi_pit
id
id_kegiatan
hasil
saran
1
1
test
test2
2
1
test3
test4
the controller;
function hasil_pit()
{
$query = $this->db->query("SELECT * FROM tbl_kegiatan_pit ORDER BY id_kegiatan");
$data['pit_kegiatan'] = $query->result();
$query1 = $this->db->query("SELECT * FROM tbl_rekomendasi_pit ORDER BY id_kegiatan");
$data['pit_rekomendasi'] = $query3->result_array();
$this->global['pageTitle'] = 'Hasil Inputan';
$this->loadViews("hasil/hasil_pit", $this->global, $data);
}
the view;
<div class="table-responsive">
<table class="table table-responsive table-bordered table-hover" style="overflow-x:auto;">
<thead style="background-color: rgba(110, 194, 132, 0.3);">
<tr class="text-center">
<th rowspan="5" style="vertical-align: middle;">No.</th>
<th colspan="2" rowspan="5"class="text-center" style="vertical-align: middle;">Kegiatan</th>
<th colspan="2" rowspan="5"class="text-center" style="vertical-align: middle;">Judul</th>
<th rowspan="3" class="text-center" style="vertical-align: middle;">Aksi</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach($pit_kegiatan as $isi) {$i++;
$id = $isi->id_kegiatan;
?>
<tr>
<td ><?=$i?></td>
<td colspan="2" style="text-align: middle; vertical-align: middle;"><?=$isi->kegiatan?></td>
<td colspan="2" style="text-align: middle; vertical-align: middle;"><?=$isi->judul?></td>
<td class="text-center"><a data-toggle="modal" data-target="#modal-<?=$id?>" class="btn btn-success waves-effect waves-light"><i class="fas fa-eye"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
the modal inside the view;
<?php
$i=0;
foreach($pit_rekomendasi as $isi) {$i++;
?>
<div class="modal fade" id="modal-<?=$isi['id_kegiatan']?>" tabindex="-1" role="dialog" aria-labelledby="modal-<?=$isi['id_kegiatan']?>" aria-hidden="true" style="overflow-y: auto;">
<div class="modal-dialog modal-dialog-centered modal-lg text-center" role="document" style="min-width: 90%;">
<div class="modal-content" style="border-radius: 20px; box-shadow: 0 0 1rem 0 rgba(0, 0, 0, 0.699); background-color: rgba(7, 3, 3, 0.685); backdrop-filter: blur(7px); min-height: 250px; border-style: solid; border-width: 3px; border-color: rgba(0, 235, 121, 0.5);">
<div class="modal-header">
<h4 class="modal-title text-center text-white" id="<?=$isi['id_kegiatan']?>">DETAIL REKOMENDASI</h4>
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="container-fluid mx-auto">
<div class="row justify-content-center">
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-bordered table-hover" style="overflow-x:auto;">
<thead style="background-color: rgba(110, 194, 132, 0.3);">
<tr class="text-center">
<th colspan="2" rowspan="5"class="text-center" style="vertical-align: middle;">No.</th>
<th colspan="2" rowspan="5"class="text-center" style="vertical-align: middle;">Hasil</th>
<th colspan="2" rowspan="5"class="text-center" style="vertical-align: middle;">Saran</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" style="text-align: center; vertical-align: middle;"><?=$i;?></td>
<td colspan="2" style="text-align: center; vertical-align: middle;"><?=html_entity_decode($isi['hasil']);?></td>
<td colspan="2" style="text-align: center; vertical-align: middle;"><?=html_entity_decode($isi['saran']);?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
<?php
}
?>
why you written 2 queries to getting one data. Just use joins to get data from both tables and use them together in foreach loop.
$data = $this->db->join('tbl_rekomendasi_pit','tbl_kegiatan_pit.id_kegiaten = tbl_kegiatan_pit.id_kegiaten')
->get('tbl_kegiatan_pit')->result_array();
It will result the joint result from both the table then you can iterate the result as per your requirement.
I am making a modal using looping data from the database on my project but I want to fetch all data in a database by selecting query GROUP BY color where id = modal id but my controller can't get the modal id which makes it error on selecting. please help me to fix it... thank you
this is the View code :
<table class="table table-bordered table-hover table table-sm" id="dataTable" width="100%" cellspacing="0">
<thead class="warna-header">
<tr>
<th rowspan="2" style="vertical-align:middle;text-align:center;">Tipe</th>
<th colspan="3" class="text-center bg-danger">1</th>
<th colspan="3" class="text-center bg-warning">2</th>
<th colspan="3" class="text-center bg-success">3</th>
<th rowspan="2" style="vertical-align:middle;text-align:center;" class="text-center">ACTION</th>
</tr>
</thead>
<tbody>
<?php foreach ($st_mobil as $st_mbl) : ?>
<tr>
<td style="font-size:12px;color:black;"><?php echo $st_mbl['jenismobil']; ?></td>
<td style="font-size:12px;color:black;text-align:center;"><?php echo $st_mbl['beli1']; ?></td>
<td style="font-size:12px;color`enter code here`:black;text-align:center;"><?php echo $st_mbl['jual1']; ?></td>
<td style="font-size:12px;color:black;text-align:center;"><?php echo $st_mbl['sisa1']; ?></td>
<td class="text-center">
<a href="" class="btn btn-success btn-sm view_detail" data-toggle="modal" title="Edit Data" data-target="#ViewStockMobilModal<?php echo $st_mbl['id']; ?>">
<span class="icon text-white-10">
<i class="fas fa-search"></i>
</span>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
-- Modal View
<?php foreach ($st_mobil as $st_mbl) : ?>
<div class="modal fade bd-example-modal-lg" id="ViewStockMobilModal<?php echo $st_mbl['id']; ?>" tabindex="-1" role="dialog"
aria-labelledby="ViewStockMobilModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header bg-primary">
<h5 class="modal-title" id="jenismobil" name="jenismobil">
<font color=white><?php echo $st_mbl['jenismobil']; ?></font>
</h5>
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<table class="table table-bordered table-striped table-sm">
<thead class="btn-primary">
<tr>
<th style="font-size:12px;" class="text-center bg-danger">ST</th>
<th style="font-size:12px;" class="text-center bg-danger">BK</th>
<th style="font-size:12px;" class="text-center bg-danger">BJ</th>
</tr>
</thead>
<?php foreach($view_detail as $vdt) : ?>
<tbody>
<tr>
<td style="font-size:12px;color:black;"><?php echo $vdt['warna']; ?></td>
<td style="font-size:12px;color:black;text-align:center;"><?php echo $vdt['st_in_1']; ?></td>
<td style="font-size:12px;color:black;text-align:center;"><?php echo $vdt['st_out_1']; ?></td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
This is the controller :
$data['st_mobil'] = $this->db->get('st_mobil')->result_array();
$id = $this->input->get($id); // i want to get the id of my modal
$data['view_detail'] = $this->stock_model->get_view_modal($id);
This is my model :
public function get_view_modal($id)
{
$query = "SELECT `id`,`jenismobil`,`warna`,`st_in_1`,`st_out_1`,`st_sisa_1`,`st_in_2`,`st_out_2`,`st_sisa_2`,`st_in_3`,`st_out_3`, st_sisa_3`
FROM `st_mobil`
GROUP BY `warna`
WHERE `id` = '$id'
";
return $this->db->query($query)->result_array();
}
When you getting the id
$id = $this->input->get('id'); // this should corrected like this.
I don't know PHP, so this might be a very basic question. I apologize in advance.
I'm working on a page that has a list of products and for each product, there is an option to delete it. The backend dev made it so it works great. However, they're not available at the moment and the client wants a modal that checks with the user if they're sure they want to delete a product before the action is complete.
I've included a modal. And just moved the delete action to the modal's 'Yes' button. However, because we have several products listed, it keeps repeating the button over and over. I realize this might be a basic fix, but I have no idea what I'm doing. Can someone please just take a look? Thank you!
Here's the (edited - I moved the action to the modal in this version) code:
<div class="container">
<div class="quotes">
<div class="col-md-12">
<div class="pages-header text-right">
New Product
</div>
</div>
<div class="col-md-12">
<div class="card rounded-0 border-0 active-products">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="mb-0">Products</h3>
</div>
<table class="table text-center" cellspacing="0">
<thead>
<tr>
<th scope="col" class="text-left quote-name">Name</th>
<th scope="col">Category</th>
<th scope="col">Hardware Price</th>
<th scope="col">Yearly License Cost</th>
<th scope="col">Monthly License Cost</th>
<th scope="col">Type</th>
<th scope="col" colspan="2"></th>
</tr>
</thead>
<tbody>
#foreach($products as $product)
<tr>
<th scope="col" class="quote-name">
{{$product->name}}
</th>
<th scope="col">
{{$product->category}}
</th>
<th scope="col">
{{$product->hardware_price}}
</th>
<th scope="col">
{{$product->yearly_license_cost}}
</th>
<th scope="col">
{{$product->monthly_license_cost}}
</th>
<th scope="col">
{{$product->type}}
</th>
<th scope="col" class="actions-col">
Edit
</th>
<th scope="col" class="actions-col">
Delete
</th>
</tr>
#endforeach
</tbody>
</table>
{{ $products->links() }}
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
#foreach($products as $product)
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<form method="POST" action="{{route('product.destroy', $product)}}" id="delete-{{$product->id}}">
#csrf
#method('DELETE')
Delete
</form>
#endforeach
</div>
</div>
</div>
</div>
</div>
How do I tweak this?
You need to use pass data attr in delete button and append into modal form using js script.
Change into HTML
Delete
Add JS Script
$(document).on('click', '.deleteproduct', function(e) {
e.preventDefault();
var id = $(this).attr('data-id');
var product = $(this).attr('data-product');
$('#Deletefrm').attr('id','delete-'+id);
$('#Deletefrm').attr('action','/product.destroy/'+product);
});
$('#deleteModal').on('hidden.bs.modal', function(e) {
$('#Deletefrm').attr('id','');
$('#Deletefrm').attr('action','');
});
Change in Modal
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<form method="POST" id="Deletefrm" action="" id="">
#csrf
#method('DELETE')
Delete
</form>
</div>
<div class="container">
<div class="quotes">
<div class="col-md-12">
<div class="pages-header text-right">
New Product
</div>
</div>
<div class="col-md-12">
<div class="card rounded-0 border-0 active-products">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="mb-0">Products</h3>
</div>
<table class="table text-center" cellspacing="0">
<thead>
<tr>
<th scope="col" class="text-left quote-name">Name</th>
<th scope="col">Category</th>
<th scope="col">Hardware Price</th>
<th scope="col">Yearly License Cost</th>
<th scope="col">Monthly License Cost</th>
<th scope="col">Type</th>
<th scope="col" colspan="2"></th>
</tr>
</thead>
<tbody>
#foreach($products as $product)
<tr>
<td scope="col" class="quote-name">
{{$product->name}}
</td>
<td scope="col">
{{$product->category}}
</td>
<td scope="col">
{{$product->hardware_price}}
</td>
<td scope="col">
{{$product->yearly_license_cost}}
</td>
<td scope="col">
{{$product->monthly_license_cost}}
</td>
<td scope="col">
{{$product->type}}
</td>
<td scope="col" class="actions-col">
Edit
</td>
<td scope="col" class="actions-col">
Delete
</td>
<td>
<div class="modal fade" id="deleteModal-{{$product->id}}" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel-{{$product->id}}" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel-{{$product->id}}">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
#foreach($products as $product)
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<form method="POST" action="{{route('product.destroy', $product)}}" id="delete-{{$product->id}}">
#csrf
#method('DELETE')
Delete
</form>
#endforeach
</div>
</div>
</div>
</div>
</td>
</tr>
#endforeach
</tbody>
</table>
{{ $products->links() }}
</div>
</div>
</div>
<!-- Modal -->
</div>
I'm facing an issue, please see the below screenshot.
Screenshot
In the screenshot, you can see its image upload page. By default, the Add Image button and the table which showing the lists should be display. The concept that I want to implement is when I click the Add Image button, the table lists should be hidden and have to show the image upload section. This all should be happen in the same URL.
Below is the code:
Route:
Route::post('/imageupload', 'Admin\ImageController#imageUploadPost')->name('image.upload.post');
Blade File:
<div class="panel panel-container">
<button type="button" class="btn btn-primary">Add Image</button>
</div>
<div class="panel panel-container">
<table class="table table-striped" id="slideshow">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
<div class="panel panel-container hide-img-upload">
<form action="{{ route('image.upload.post') }}" method="POST" enctype="multipart/form-data">
#csrf
<div class="row">
<div class="col-md-6">
<input type="file" name="image" class="form-control">
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-success">Upload</button>
</div>
</div>
</form>
</div>
</div>
Controller:
public function imageUploadPost()
{
return back()
->with('success','You have successfully upload image.')
->with('image',$imageName);
}
Since, I'm new to Laravel, I couldn't able to see the solution.
Any help will be appreciated.
Try this
<div class="panel panel-container">
<button type="button" class="btn btn-primary"data-toggle="modal"data-target="#myModal">Add Image</button>
</div>
<div class="panel panel-container">
<table class="table table-striped" id="slideshow">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
<div class="modal" id="myModal" role="dialog"
aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Upload Image </h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="container"></div>
<div class="panel panel-container hide-img-upload">
<form action="{{ route('image.upload.post') }}" method="POST" enctype="multipart/form-data">
#csrf
<div class="row">
<div class="col-md-6">
<input type="file" name="image" class="form-control">
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-success">Upload</button>
</div>
</div>
</form>
</div>
</div>
</form>
</div>
</div>
or use javascript hidden show for this
this is more about html and javascript staff.
You can use this as hint.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<button onclick="alter()">Alter</button>
<div id="first">First</div>
<div id="sec">Second</div>
<script>
document.getElementById('sec').style.visibility = 'hidden';
function alter(){
if(document.getElementById('sec').style.visibility == 'hidden'){
document.getElementById('sec').style.visibility = 'visible';
document.getElementById('first').style.visibility = 'hidden';
}else{
document.getElementById('sec').style.visibility = 'hidden';
document.getElementById('first').style.visibility = 'visible';
}
}
</script>
</body>
</html>
Firstly define id for file input;
<input type="file" name="image" id="file_input" class="form-control">
After define id for list scope;
<div class="panel panel-container" id="list_scope">
Finally add JavaScript codes;
<script>
document.getElementById('file_input').onclick = function() {
document.getElementById('list_scope').style.display = "none";
};
</script>
I am working on a project, where I have created a catalog for company. On some pages when user clicks on product id, a modal displays product detail. The modal works fine when there are values in rows. However, when there are null values, the modal comes back empty. How do I handle the code so that even if there are null values in some rows, data will still be displayed? Or is there an easier way to show show product detail without using modal/ajax/json.
MYSQL Query
if($_REQUEST['tid']) {
SELECT t.tool_id, power_source, sub_option, sub_type,
(purchase_price * 0.15) AS rental_price, (purchase_price * 0.4) AS
deposit_price, material,manufacturer, length, width_diameter, weight,
ac.accessory_description FROM tool t JOIN accessory ac on t.tool_id =
ac.tool_id WHERE tool_id='".$_REQUEST['tid']."'";
$resultset = mysqli_query($connection, $sql) or die("database error:".
mysqli_error($connection));
$data = array();
while( $rows = mysqli_fetch_assoc($resultset) ) {
$data = $rows;
}
echo json_encode($data);
} else {
echo 0;
}
?>
Ajax/json code
$(document).ready(function(){$(document).on
('click', '#getTool', function(e){ e.preventDefault();
var tid = $(this).data('id');
$('#tool-detail').hide();
$('#tool_data-loader').show();
$.ajax({url: 'toolData.php',
type: 'POST',
data: 'tid='+tid,
dataType: 'json',
cache: false
})
.done(function(data){
console.log(data.id);
$('#tool-detail').hide();
$('#tool-detail').show();
$('#tid').html(data.tool_id);
$('#tool_type').html(data.power_source);
$('#short_desc').html(data.sub_option + " " +data.sub_type);
$('#fullDesc').html(data.manufacturer+ " "+data.material+ ",
"+data.length+"in x " +data.width_diameter+"in,"+data.weight+"lbs");
$('#rental_price').html("$"+data.rental_price);
$('#deposit_price').html("$"+data.deposit_price);
$('#accessories').html("$"+data.accessory_description);
$('#tool_data-loader').hide();
})
.fail(function(){
$('#tool-detail').html('Error, Please try again...');
$('#tool_data-loader').hide();
});
});
});
Modal
<form action="productDetail.php" method="post">
<table>
<tr>
<td><input type="submit" name="productDetail" value="productDetail" id="productDetail" style="margin-left: 10px;"></td>
</tr>
</table>
</form>
<div id="tool-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">*</button>
<h4 class="modal-title">
<i class="glyphicon glyphicon-wrench"></i> Tool Details
</h4>
</div>
<div class="modal-body">
<div id="tool_data-loader" style="display: none; text-align: center;">
<img src="ajax-loader.gif">
</div>
<div id="tool-detail">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-bordered">
<tr>
<th>Tool ID</th>
<td id="tid"></td>
</tr>
<tr>
<th>Tool Type</th>
<td id="tool_type"></td>
</tr>
<tr>
<th>Short Description</th>
<td id="short_desc"></td>
</tr>
<tr>
<th>Full Description</th>
<td id="fullDesc"></td>
</tr>
<tr>
<th>Rental Price</th>
<td id="rental_price"></td>
</tr>
<tr>
<th>Deposit Price</th>
<td id="deposit_price"></td>
</tr>
<tr>
<th>Accessories</th>
<td id="accesories"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>