"plame"
Bootstrap 4.1.1 Snippet by luchonia

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <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"> SPP </th> <th class="text-center"> BASICO </th> <th class="text-center"> ESSALUD ONP 10% </th> <th class="text-center"> PRIMA AFP (NO ES ONP 12%) </th> </tr> </thead> <tbody> <tr id='addr0'> <td class="text-center">1</td> <td class="text-center"><select id="combobox" name='afp[]' class="center afp"> <option value="-1" step="0" min="0">#</option> <option value="0" step="0" min="0">HORIZONTE</option> <option value="0" step="0" min="0">PROFUTURO</option> <option value="1" step="0" min="0">ONP</option> </select> </td> <td><input type="number" name='basico[]' class="form-control basico" step="0" min="0"/></td> <td><input type="number" name='essalud[]' placeholder='0.00' class="form-control essalud" readonly/></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> <div class="row clearfix" style="margin-top:20px"> <div class="pull-right col-md-4"> <table class="table table-bordered table-hover" id="tab_logic_total"> <tbody> </tbody> </table> </div> </div> </div>
$(document).ready(function(){ 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>'); i++; $('#tab_logic tbody td').on('keyup change',function(){ llenar(); }); }); $("#delete_row").click(function(){ if(i>1){ $("#addr"+(i-1)).html(''); i--; } }); $('#tab_logic tbody tr').on('keyup change',function(){ llenar(); }); }); function llenar() { $('#tab_logic tbody tr').each(function(i, element) { var html = $(this).html(); if(html!='') { if($(this).find('.afp').val()==1){ calcOnp(); }else if($(this).find('.afp').val()==0){ calcFp(); }else{ } } }); } function calcOnp() { $('#tab_logic tbody tr').each(function(i, element) { var html = $(this).html(); if(html!='') { var qty = $(this).find('.basico').val(); $(this).find('.total').val(qty*0.0); $(this).find('.essalud').val(qty*0.1); } }); } function calcFp() { $('#tab_logic tbody tr').each(function(i, element) { var html = $(this).html(); if(html!='') { var qty = $(this).find('.basico').val(); $(this).find('.essalud').val(qty*0.0); $(this).find('.total').val(qty*0.12); } }); }

Related: See More


Questions / Comments: