几天前,我在表中编写了一个产品添加代码,并将其总成本计算为添加产品的总成本,并在我添加(选择)计费表中的产品时提交数据库位中的列表,这些添加产品的名称没有得到发布,这是我通过分析我的结果得到的,这是我的代码::
控制器:
$common['extra_fee_list']='';
$sql2="SELECT * FROM fee_additional_fee";
$query2 = $this->db->query($sql2);
foreach ($query2->result_array() as $row2)
{
$common['extra_fee_list']=$common['extra_fee_list'].' <tr> <td>
<input type="checkbox" class="checkBoxClass" name="additional_fee_code[]" value="'.$row2['id'].'"/> </td>
<td>'.$row2['cause_addition_fee'].'</td> <td>'.$row2['fee'].'</td> </tr> '; //here agin plz take input in arry ----additional_fee_code will work for next method (cal_total_extra_fee())
} // name (additional_fee_code[]) not getting posted
//this code id only for printing the list to be added
这是我的看法::
<form method="post" action="<?php echo site_url('fee_related/cal_total_extra_fee')?>">
<div class="block-content">
<p> </p>
<div class="_25">
<?php echo form_dropdown('class', $dropdown_class); ?>
<?php echo form_dropdown('section',$dropdown_section); ?>
</div>
<table id="table-example" class="table">
<tr>
<th>Cause</th>
<th>Monthly Charge</th>
</tr>
<tbody id="selectedServices"></tbody>
<tr>
<td>Total</td>
<td id="total">1500</td> <!-- get the value from datbase and also in javascript!-->
</tr>
</table>
<div class="clear"></div>
<p> </p>
<div class="block-actions">
<ul class="actions-left">
<li><a class="button red" id="reset-validate-form" href="javascript:void(0);">Reset</a></li>
</ul>
<ul class="actions-right">
<li><input type="submit" class="button" value="Alot!!"></li>
</ul>
</div>
</div>
</form>
和JS:
<script src="<?php echo $base_url; ?>assets/js/libs/jquery-1.9.1.js"></script>
<SCRIPT language="javascript">
$(function () {
$(":checkbox").change(function () {
// Toggle class of selected row
$(this).parent().toggleClass("rowSelected");
// Get all items name, sum total amount
var sum = 1500;
var arr = $(":checkbox:checked").map(function () {
sum += Number($(this).parents('tr').find('td:last').text());
return $(this).parents('tr').clone();
}).get();
// Display selected items and their sum
$("#selectedServices").html(arr).find('input').remove();
$("#total").text(sum);
});
});
</script>