Hi Does anyone know what i'm doing wrong here. Instead of adding my numbers together its putting them next to each other?
This is the javascript...
This is the form...Code:<SCRIPT LANGUAGE="JavaScript"> <!-- var myIncome1; var myIncome2; var myIncome3; var myIncome4; function HowMany(form) { var totalincome; totalincome = (myIncome1 + myIncome2 + myIncome3 + myIncome4); form.Tincome.value = totalincome; } function SetMyIncome1(inc1) { myIncome1 = inc1.value; } function SetMyIncome2(inc2) { myIncome2 = inc2.value; } function SetMyIncome3(inc3) { myIncome3 = inc3.value; } function SetMyIncome4(inc4) { myIncome4 = inc4.value; } function ClearForm(form){ form.myIncome1.value = ""; form.myIncome2.value = ""; form.myIncome3.value = ""; form.myIncome4.value = ""; form.Tincome.value = ""; } // --> </SCRIPT>
Code:<div><form method="Post"> <div><p>Monthly income</p></div> <div><p>Pay <input name="myIncome1" type="text" ONCHANGE="SetMyIncome1(this)"/></p> <p>Benefits <input name="myIncome2" type="text" ONCHANGE="SetMyIncome2(this)"/></p> <p>Pension <input name="myIncome3" type="text" ONCHANGE="SetMyIncome3(this)"/></p> <p>Other income <input name="myIncome4" type="text" ONCHANGE="SetMyIncome4(this)"/></p> <p><INPUT TYPE=BUTTON ONCLICK="HowMany(this.form)" VALUE="Calculate Income"><INPUT TYPE=BUTTON VALUE=" Reset " onClick="ClearForm(this.form)"></p> <p>Total <input name="Tincome" type="text" value="" /></p></div></form


Reply With Quote

Bookmarks