I want to calculate using jQuery keyup function.
Total Price = Quality x Unit Cost Price
Total Price = Quality x Unit Selling Price
jQuery:
$('input').keyup(function(){
//calculate
});
The problem is: when I click add price button, the new rows are added. How to call the new row id?
HTML:
<div class="price_table">
<div class="row">
<div class="span5 offset1"><h1>Price Breakdown<h1></div>
<div class="span4 offset1"><input type="button" id="add_price" class="btn btn-primary" value="Add Price" style="float:right;margin:30px 0px 5px 0px;"/></div>
</div>
<div class="row">
<div class="span10 offset1">
<table class="addcost_table table tablesorter">
<thead>
<tr class="header_row">
<th>Item Group</th>
<th>Name</th>
<th>Code</th>
<th>Quantity</th>
<th class="cost_price">Unit Cost Price</th>
<th class="selling_price">Unit Selling Price</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= form_input('items[0][sub_header]', 'Hotel') ?></td>
<td><?= form_input('items[0][name]', 'Twin Room') ?></td>
<td><?= form_input('items[0][price_type]', 'TWN') ?></td>
<td><?= form_input('items[0][quantity]', '5') ?> </td>
<td class="cost_price"><?= form_input('items[0][cost]', '100') ?> </td>
<td class="selling_price"><?= form_input('items[0][price]', '120') ?> </td>
</tr>
<tr>
<td><?= form_input('items[1][sub_header]', 'Hotel') ?></td>
<td><?= form_input('items[1][name]', 'Single Room') ?></td>
<td><?= form_input('items[1][price_type]', 'SGL') ?></td>
<td><?= form_input('items[1][quantity]', '1') ?> </td>
<td class="cost_price"><?= form_input('items[1][cost]', '80') ?> </td>
<td class="selling_price"><?= form_input('items[1][price]', '100') ?> </td>
</tr>
<tr>
<td><?= form_input('items[2][sub_header]', 'Meals') ?></td>
<td><?= form_input('items[2][name]', 'Buffet Breakfast') ?></td>
<td><?= form_input('items[2][price_type]', 'BRE') ?></td>
<td><?= form_input('items[2][quantity]', '2') ?> </td>
<td class="cost_price"><?= form_input('items[2][cost]', '10') ?> </td>
<td class="selling_price"><?= form_input('items[2][price]', '10') ?> </td>
</tr>
<tr>
<td colspan="4" style="text-align:right;margin-right:10px;"><b><span style="margin-right:20px;">Total Price X Qty</span></b></td>
<td class="cost_price"><?= form_input('items[3][cost]', '600') ?></td>
<td class="selling_price"><?= form_input('items[3][cost]', '500') ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="span11 offset1">
<?= form_submit(array('class' => 'btn btn-primary'), 'Submit') ?>
</div>
</div>
</div>
Thanks a lot my friends.