I have a JQuery function, on which i am trying to simply apply the multiplication of 2 inputs onto a 3rd input.
But, for some reason, it isn't working. What i basically want to do, is for the result to automatically appear on the 3rd input, after i have values on the first 2
I tried searching for an answer, but maibe due to inexperience, i am unable to use the correct keywords. Sorry for that
<html> <head> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" > $(document).ready(function () { $(".txtMult input").keyup(multInputs); function multInputs() { var mult = 0; // for each row: $("txtMult").each(function () { // get the values from this row: var $val1 = $('.val1', this).val(); var $val2 = $('.val2', this).val(); var $total = ($val1 * 1) * ($val2 * 1) $('.multTotal',this).text($total); mult += $total; }); }); </script> </head> <body> <div class="txtMult"> <div class="row"> <label for="name">Comprimento em centimetros:</label><br /> <input id="cmp" class="val1" name="cmp" type="text" value="" size="30" /><br /> </div> <div class="row"> <label for="email">Largura em centimetros:</label><br /> <input id="lrg" class="val2" name="lrg" type="text" value="" size="30" /><br /> </div> <div class="row"> <label for="email">Área em M<small>2</small></label><br /> <div class='section'> <input id="lrg" class="multTotal" name="lrg" type="text" value="" size="30" /><br /> </div> </div> </div> </body> </html>