Creating a calculated Field in a form and showing the results

Here is a bit of javascript to show a calculated field on a form.


<br>  /* only allow numbers to be entered */<br>  $('%CONTENT_ROW.ROW_ID%').find(".f119704 input[type=text]").keydown(function(e){<br>    if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||<br>             // Allow: Ctrl+A, Command+A<br>            (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) || <br>             // Allow: home, end, left, right, down, up<br>            (e.keyCode >= 35 && e.keyCode <= 40)) {<br>                 // let it happen, don't do anything<br>                 return;<br>        }<br>        // Ensure that it is a number and stop the keypress<br>        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {<br>            e.preventDefault();<br>        }<br>  });<br>  /* do the calculation and output the results */<br>  $('%CONTENT_ROW.ROW_ID%').find(".f119704 input[type=text]").keyup(function(){<br>    var patients = parseInt($(this).val());<br>    var quote = (patients*104.92).toFixed(2);<br>    <br>    $(".quote-value").text("$" + quote);<br>    $('%CONTENT_ROW.ROW_ID%').find("input[type=hidden]").val(quote);<br>  });<br>



Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.