"Product Invoice Dynamic Table with Alert"
Bootstrap 3.3.0 Snippet by viswa

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row clearfix">
<div class="col-md-12">
<table class="table table-bordered table-hover" id="tab_logic">
<thead>
<tr>
<th class="text-center"> # </th>
<th class="text-center"> Product </th>
<th class="text-center"> Qty </th>
<th class="text-center"> Price </th>
<th class="text-center"> Total </th>
</tr>
</thead>
<tbody>
<tr id='addr0'>
<td>1</td>
<td><select class="form-control" name='product[]' onChange="option_checker(this);"></select></td>
<td><input type="number" name='qty[]' placeholder='Enter Qty' class="form-control qty" step="0" min="0"/></td>
<td><input type="number" name='price[]' placeholder='Enter Unit Price' class="form-control price" step="0.00" min="0"/></td>
<td><input type="number" name='total[]' placeholder='0.00' class="form-control total" readonly/></td>
</tr>
<tr id='addr1'></tr>
</tbody>
</table>
</div>
</div>
<div class="row clearfix">
<div class="col-md-12">
<button id="add_row" class="btn btn-default pull-left">Add Row</button>
<button id='delete_row' class="pull-right btn btn-default">Delete Row</button>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
#tab_logic .form-control[readonly],#tab_logic_total .form-control[readonly] {
border: 0;
background: transparent;
box-shadow: none;
padding: 0 10px;
font-size: 15px;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$(document).ready(function(){
option_list('addr0');
var i=1;
$("#add_row").click(function(){b=i-1;
$('#addr'+i).html($('#addr'+b).html()).find('td:first-child').html(i+1);
$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
option_list('addr'+i);
i++;
});
$("#delete_row").click(function(){
if(i>1){
$("#addr"+(i-1)).html('');
i--;
}
calc();
});
$(".product").on('change',function(){
option_checker(this)
});
$('#tab_logic tbody').on('keyup change',function(){
calc();
});
$('#tax').on('keyup change',function(){
calc_total();
});
});
function option_checker(id)
{
var myOption=$(id).val();
var s =0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments:

small - correction : you have added the alert but when you select okay on java script alert product drop-down should be set to select product again.

tusharuit25 () - 4 years ago - Reply 0