Trying to pull information from my form input fields and calculate them using JavaScript. It does not seem to be working.
HTML (default1.html)
<script type="text/javascript" src="multiplication.js" language="javascript"></script>
<form>
<table>
<tr><!--Row 2-->
<td class="tdSize7">
<input class="input" name="name1" type="text"/>
</td>
<td class="tdSize7">
<input class="input" name="source1" type="text"/>
</td>
<td class="tdSize8">
<p>$</p>
</td>
<td class="tdSize9">
<input class="input" name="income1" type="text"/>
</td>
<td class="tdSize8">
<p>X12</p>
</td>
<td class="tdSize8">
<p>$</p>
</td>
<td class="tdSize9">
<input name="ann1" disabled="disabled"/>
</td>
</tr>
<td class="tdSize9"><input class="inputSize2" name="" type="button" value="Calculate" onclick="addme(this.form)"/></td>
</table>
</form>
JavaScript (multiplication.js)
function addme(form) {
//Constant Variables
const twelve = Number (12);
const fourHun = Number (400);
const fourHunEighty = Number (480);
//Monthly Income 1
var income1 = Number(frm.income1.value);
var val = income1 * twelve;
frm.ann1.value = val;
}
My JavaScript will not calculate and input my results back into my form.
This is just a sample of my code. I am hoping this will tell you enough and help you, in helping me fixing my problem.
Did you intend to use
forminstead offrm? That is part of your problemTry:
Or change
to