动态地将产品添加到定价表并发布到数据库

时间:2013-06-05 08:47:15

标签: php codeigniter

前几天我在表格中编写了一个产品添加项,并计算了总成本作为产品的新增成本,并在我在添加(选择)计费表中的产品时提交数据库位列表,这些产品的名称没有发布,我通过分析我的结果得到的是我的代码::

控制器:

    $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>&nbsp;</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>&nbsp;</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>

0 个答案:

没有答案