So, I have a form where people can enter the number of t-shirts they for want each size and I have a script that sums it up as they tab off of each form element. I also send in the number of total registrants they have to that page. What I would like to do is check on form submission to make sure that the total number of shirts they have requested is equal to the number of registrants that they have.
So, here is the incoming number of spaces they have
Here is the script that does the calculation
Here is the call to the script in the code
and here is the call to submit the page
Any ideas, thoughts or suggestions to make this work would be very much appreciated.
Thanks,
Willie
So, here is the incoming number of spaces they have
Code:
Dim num : num = request("num")
Here is the script that does the calculation
Code:
<script language="JavaScript" type="text/javascript">
function calculate(el)
{
var form = el.form;
var xsmall = Number(form.elements["xsmall"].value );
var small = Number(form.elements["small"].value );
var medium = Number(form.elements["medium"].value );
var large = Number(form.elements["large"].value );
var xlarge = Number(form.elements["xlarge"].value );
var xxlarge = Number(form.elements["xxlarge"].value );
var total = xsmall + small + medium + large + xlarge +xxlarge;
// Check for user entry errors
if (isNaN(total)) {
// Alert user of error
alert("Please enter only numbers");
} else {
// Show total in the form field, and select the form field text
form.elements["total"].value = total;
//form.elements["total"].select();
}
}
</script>
Here is the call to the script in the code
Code:
<input name="total" type="text" id="total" size="4" onfocus="calculate(this)">
and here is the call to submit the page
Code:
<input type="image" name="submit" id="submit" src="/images/submit_blue.gif" onmouseover='this.src="/images/submit_green.gif"'; onmouseout='this.src="/images/submit_blue.gif"'; value="Submit >>" width="112" height="32">
Any ideas, thoughts or suggestions to make this work would be very much appreciated.
Thanks,
Willie