jquery - javascript multiply input by number -
i'm trying create simple function table have been tasked creating. want user enter number first input field, , have number multiplied 30, , have result show in second input field, keyup or onchange.
here's have far, please keep in mind i'm very new @ this.
<table> <tr> <td>costs</td> <td>$ <input type="text" id="daily"> </td> <td>$ <input type="text" id="result"> </td> </tr> </table> <script> $(function () { $('#daily').keyup(function () { var daily = $('#daily').val(); var month = 30; $('#result').val(daily * month); }); }); </script>
$(function () { $('#daily').on('keyup', function (){ var daily = parseint($('#daily').val()); var month = 30; $('#result').val(daily * month); }); });
i tried use ".on" binding instead of directly using ".keyup" because prevent errors if table result of ajax call
Comments
Post a Comment