<table class="table table-striped table-sm" data-maxrow="10" data-minrow="1"> <thead> <tr> <th class="bg-light"><label for="item_testname_id"><?php print_lang('item_testname_id'); ?></label></th> <th class="bg-light"><label for="unit_price"><?php print_lang('unit_price'); ?></label></th> <th class="bg-light"><label for="quantity"><?php print_lang('quantity'); ?></label></th> <th class="bg-light"><label for="total_price"><?php print_lang('total_price'); ?></label></th> <th></th> </tr> </thead> <tbody> //here is using forloop function create dynamic table row <?php for( $row = 1; $row <= 1; $row++ ){ ?> <tr class="input-row"> <td> <div id="ctrl-item_testname_id-row<?php echo $row; ?>-holder" class=""> <select required="" id="ctrl-item_testname_id-row<?php echo $row; ?>" data-load-select-options="unit_price" name="row<?php echo $row ?>[item_testname_id]" placeholder="<?php print_lang('select_a_value_'); ?>" class="custom-select" > <option value=""><?php print_lang('select_a_value_'); ?></option> <?php $item_testname_id_options = $comp_model -> pat_direct_billing_list_item_testname_id_option_list(); if(!empty($item_testname_id_options)){ foreach($item_testname_id_options as $option){ $value = (!empty($option['value']) ? $option['value'] : null); $label = (!empty($option['label']) ? $option['label'] : $value); $selected = $this->set_field_selected('item_testname_id',$value, ""); ?> <option <?php echo $selected; ?> value="<?php echo $value; ?>"> <?php echo $label; ?> </option> <?php } } ?> </select> </div> </td> <td> <div id="ctrl-unit_price-row<?php echo $row; ?>-holder" class=""> <select required="" id="ctrl-unit_price-row<?php echo $row; ?>" data-load-path="<?php print_link('api/json/pat_direct_billing_list_unit_price_option_list') ?>" name="row<?php echo $row ?>[unit_price]" placeholder="<?php print_lang('select_a_value_'); ?>" class="custom-select" > <option value=""><?php print_lang('select_a_value_'); ?></option> </select> </div> </td> <td> <div id="ctrl-quantity-row<?php echo $row; ?>-holder" class=""> <input id="ctrl-quantity-row<?php echo $row; ?>" value="<?php echo $this->set_field_value('quantity',"1", $row); ?>" type="text" placeholder="<?php print_lang('enter_quantity'); ?>" required="" name="row<?php echo $row ?>[quantity]" class="form-control " /> </div> </td> <td> <div id="ctrl-total_price-row<?php echo $row; ?>-holder" class=""> <input id="ctrl-total_price-row<?php echo $row; ?>" value="<?php echo $this->set_field_value('total_price',"", $row); ?>" type="text" placeholder="<?php print_lang('enter_total_price'); ?>" required="" name="row<?php echo $row ?>[total_price]" class="form-control " /> </div> </td> <th class="text-center"> //here is delete button <button type="button" class="close btn-remove-table-row">×</button> </th> </tr> <?php } ?>//end forloop </tbody> <tfoot> <tr> <th colspan="100" class="text-right"> <?php $template_id = "table-row-" . random_str(); ?> <button type="button" data-template="#<?php echo $template_id ?>" class="btn btn-sm btn-light btn-add-table-row">class="fa fa-plus"></button> </th> </tr> </tfoot> </table>
total=0; for($row = 1; $row <= 1; $row++){ total_price = document.getElementById('ctrl-total_price-row'+$row).value; quantity = document.getElementById('ctrl-quantity-row'+$row).value; r =(total_price*quantity); total+=r; document.getElementById('ctrl-total_price-row'+$row).innerHTML = r +; }
document.getElementById
for($row = 1; $row <= 1; $row++)
CalculateGrandTotal
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)