I have three td's in a table. Two of which are inputs which I multiply and spit out the answer to the third td. I initially had a span in that td, but I need an input box instead. With the span it works great, but once I put the input in it doesn't.
How can I use this small Jquery function to display the result in the input versus the span?
Here's the td:
<td> @* 11 *@
<span class="mcalPremium"></span> //Multiplied answer goes here, but want it in the TB instead
@*<input type="number" class="form-control mcalPremium" />*@//Commented out to try both.
</td>
Here is the function:
$("#alSublineValSubmitTBL").on('input', 'td:nth-child(11)', function () {
var td = $(this);
var input1 = +td.find('input').val() || 0;
var input2 = +td.parent().find("td:nth-child(9) input").val() || 0;
var exp = parseInt(input1);
var rate = parseFloat(input2);
var premium = rate * exp;
//display premium in premium field
td.parent().find('.mcalPremium').text('$' + premium).digits();
//td.parent().find('.mcalPremium').val('$' + premium).digits();
});
EDIT and UPDATE: The error was hidden among many other console.out pieces that I just simply missed. .val does actually function how I thought it did, but I had that dollar sign in the val() "val('$' + premium)" causing the error. Removing it resolved the issue and it works as needed.