Help on forms & tables - Problem getting rows & columns to calculate
I have a website at http://www.oceangift1.com, along with my friend in South Carolina. I am completely new at the art of web page building, and this is the first one I have ever built.
I'm wondering if you could look at that site, particuliary tht Order Form. I want to know the HTML to insert to make the rows calculate and the last column calculate and total the items.
Thanks for your kind help. Please e-mail me the HTML and I will copy it to the page
Sincerely,
modiggerp
PJ posted this at 21:54 — 30th July 1999.
They have: 76 posts
Joined: Apr 1999
This will not be possible in HTML alone. You will need to use some scripting (Java or VB) to get the calculations you're asking for.
If you are familiar with scripting it's really simple. Just add a little recalculate order button, or the script can do it automatically for you whenever one of the boxes change.
I don't really have the time to write out the script for your site since I'm being paid to work for someone else , but the first thing you'll have to do is name the form, it will be easier in the script to refer to the form name. I'll provide a little sample of some script that you can use on your site. For now let's say the form is called order.
<script LANGUAGE="javascript">
<!--
function computeForm(input)
{
form = document.order;
// Guard against empty values to prevent JavaScript Errors (NaN)
if (isNaN(form.r-item1price.value)) {
alert("Invalid input, use only numbers.");
form.r-item1price.focus();
}
if (isNaN(form.r-item1qty.value)) {
alert("Invalid input, use only numbers.");
form.r-item1qty.focus();
}
if (isNaN(form.r-item1total.value)) {
alert("Invalid input, use only numbers.");
form.r-item1total.focus();
}
if ((form.r-item1price.value == null ¦¦ form.r-item1price.value.length == 0)) {
form.r-item1price.value = 0;
}
if ((form.r-item1qty.value == null ¦¦ form.r-item1qty.value.length == 0)) {
form.r-item1qty.value = 0;
}
if ((form.r-item1total.value == null ¦¦ form.r-item1total.value.length == 0)) {
form.r-item1total.value = 0;
}
form.r-item1total.value = parseFloat(form.r-item1price.value) * parseFloat(form.r-item1qty.value);
}
//-->
</script>
That will do the first item in your order form, just repeat it for all the others. Then to total just add all the r-item1 - 8total boxes together. Then like I said before just assign this action to a button or an onchange event and everything should be fine. You can always give the total boxes read only access that way nobody can mess up the totals.
If you don't understand scripting I guess this was kind of pointless, if that's the case I hope this was a learning experience for someone
Later,
PJ
P.S. Any errors in the above script are due to the fact that it was written without testing, not advisable
modiggerp posted this at 22:34 — 30th July 1999.
They have: 2 posts
Joined: Jun 1999
To: PJ
From: Modiggerp
Thanks so very much for your quick response to my post. I really appreciate this information. After previewing it, I think I'll be ok. I will post my results to you in a week or so. Take care, and God Bless. Tom Moan, the modiggerp
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.