Seafury888
Programmer
I'm making a web page that calculates the total of T-shirts purchased using a check() function, called by a button, in a form. Heres the important info.
1. The actual name of my form:
2. The actual code for the button:
//Note: my document's name is form.html, I have tried the syntax: check(this.form), check(form), check()...
3. The code for the check() function is:
When I enter values in the text fields and click the button to calculate the total, I get the error "Object Expected" on the line containing the button code.
Any help with this problem is greatly appreciated.
Ian
1. The actual name of my form:
Code:
<form method="POST" name="form" action="--WEBBOT-SELF--">
2. The actual code for the button:
Code:
<input type="button" value="Calculate Total" name="B3" onClick="check(form.form)">
3. The code for the check() function is:
Code:
<!--
<script type="text/javascript">
function check(form)
{//check all the t-shirt text fields for non-numeric data
for (i=13; i<form.length-2; i++)
{
if(isNaN(form.elements[i].value)
{
alert("You Must Enter a Number for "+ form.elements[i].name);
form.elements[i].value = "";
form.elements[i].focus();
return;
}
}
//all T-shirts contain numeric data
//first T-shirt text box is entity #13, calculation adds up entities 13-16, and puts them in the "Total" entity.
var total = 0;
for(i=13; i<form.length-2; i++)
total = (total + parseFloat(form.elements[i].value))*18.00;
form.Total.value = total + 5.00;
-->
When I enter values in the text fields and click the button to calculate the total, I get the error "Object Expected" on the line containing the button code.
Any help with this problem is greatly appreciated.
Ian