Saturday, 15 March 2014

multiply text value and display answer jquery -



multiply text value and display answer jquery -

i trying multiply value generated using jquery, static value. have done when value coming text box, not span tag.

the script below works when taking value textbox. how can modify read teh

here have far:

html file want multiply static value by

<p id="sum" name="equip_amount_four"></p>

this place want place reply of static value html above

<p>$ <span id="equippymnt" name="equip_payment"></span></p>

jquery

<script> var multiplyshares = function() { var val1 = parsefloat($('#shares').val()) var val2 = .086667 val3 = val1 * val2 || "invalid number" $("#result").html(val3.tofixed(2)) } $("#shares").keyup(function() { multiplyshares(); }); </script>

it looks have few mismatched ids in html. next works:

class="snippet-code-js lang-js prettyprint-override">var multiplyshares = function() { var val1 = parsefloat($('#sum').text()); var val2 = .086667; var val3 = val1 * val2; val3 = isnan(val3) ? "invalid number" : val3.tofixed(2); $("#equippymnt").html(val3); } multiplyshares(); class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <p id="sum" name="equip_amount_four">500</p> <p>$ <span id="equippymnt" name="equip_payment"></span></p>

jquery

No comments:

Post a Comment