I have this code that is not working. I am trying to multiply 2 textboxs and show the solution, but it doesn’t show anything when I click. The code I have so far is this… what can be wrong with the code below?
<script type="text/javascript">
$('#AddProduct').click(function() {
var totalPrice = $('#debt').val() * $('#income').val();
$('#solution').val() = totalPrice;
});
</script>
<form name="form" method="post" action="">
<table>
<tr>
<td><input type="text" name="income" id="income" /></td>
<td><input type="text" name="debt" id="debt" /></td>
<td><input type="text" id="solution" name="solution" /> </td>
</tr>
</table>
</form>
After, you add jquery to your page as below
you can do the following:
You have to tell it you want the
valueof the input you are targeting.And also, always provide the second argument (radix) to
parseInt. It tries to be too clever and autodetect it if not provided and can lead to unexpected results.Providing
10assumes you are wanting a base 10 number.