php - Calculations with javascript -




i found script , kind of need learn right now.

similar code

i want data php , date calculation!

but dont understand how yet!

$(window).load(function(){      $('div#cont-sum-fields').on('change', 'input', function() {  //        var total =  (parseint($( "#cont-sum-1" ).val()) +  parseint($( "#cont-sum-2" ).val())) * parseint($( "#cont-sum-3" ).val()) ;   var printsmall = 6;  //var pricesmall = <? echo $priceaud[4][2];?>; // output 6.0          var total =  (parseint($( "#cont-sum-1" ).val()) +  parseint($( "#cont-sum-2" ).val())) * pricesmall) ;          $('#cont-sum-fields').find('#total-cont-sum').val(total);          find('pricesmall').val(pricesmall);      });  }); 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>      <div id='cont-sum-fields'>      (<input type="number" id="cont-sum-1" /> +      <input type="number" id="cont-sum-2" />) x      <input id="pricesmall" type="number" disabled /> =      <input id="total-cont-sum" type="number" disabled />    </div>  

so little summary of want done:

first number + second number * php or var printsmall = total!

here code modified in way think want it.

please note indentation etc, makes reading code easier.

$(window).load(    function(){      var printsmall = 6;      $('#pricesmall').val(printsmall);      $('#cont-sum-fields').on('change', 'input',         function() {          var             s1 = $('#cont-sum-1').val(),            s2 = $('#cont-sum-2').val();           if (s1 && s2) {            $('#total-cont-sum').val(              (parsefloat(s1) + parsefloat(s2)) * printsmall);          }        }      )    }  );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>      <div id='cont-sum-fields'>      (<input type="number" id="cont-sum-1" /> +      <input type="number" id="cont-sum-2" />) x      <input id="pricesmall" type="number" disabled /> =      <input id="total-cont-sum" type="number" disabled />    </div>





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -