Scott Christy

Greenhorn
+ Follow
since Sep 23, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Scott Christy

That's an excellent point. Probably the best solution is to make 2 separate buttons. One to print and then one to finish the processing of the order.

Besides, it would sure make the programming easier on my end.

Thanks for the advice.
Help!

I'll get right to the point. Is it possible to have a form submit button do more than one action? I want a form button that when clicked first will send the current window to the printer (which I know how to do) and then second will send data from a cookie file to a CGI script (which I also know how to do). The problem is making the button do both actions.

If you want to see the situation I'm using this for go to:
www.greenbayeasthighschool.com/store/commerce.cgi

when you get there, put an item in the shopping cart and go to the checkout. Put any data in the billing and shipping screen and click verify. In the next screen you'll see my print button at the bottom of the screen. This button prints the summary screen from further up on the page. The problem is, it doesn't empty the shopping cart items since it doesn't call the script that empties the cart and responds with an order confirmation screen. Is it possible to make the button do both actions?

Before anyone asks why I'm not using paypal or something like that to process the orders, it's because the people I'm building this for don't want to accept anything but checks or money orders yet.

Any help would be, of course greatly appreciated!
Good to know. Eric, Thanks for all your help.
I changed the line that says:
form.grandtotal.value = Math.round((parseInt(form.tax.value) + parseInt(form.subtotal.value)) * 100)/100;
to
form.grandtotal.value = Math.round((parseFloat(form.tax.value) + parseFloat(form.subtotal.value)) * 100)/100;
and it seems to work ok. Is this the right technique to use?
That worked perfect for rounding the values to the nearest dollars and cents. I'm left with one last problem. When the subtotal and the tax are added together it appears to be rounding off to the nearest whole dollar value. For example, in the script below, if the subtotal calculates to 30 and the tax is 1.65 the answer given for the total is 31. It shoudl be 31.65.

[edited to fit page: Eric]
[ September 29, 2003: Message edited by: Eric Pascarello ]
In case you're interested, below is a link to a DHTML menu that works great on any platform. I've used it on the site I run for my school and it works great. You might want to check it out.
http://www.dynamicdrive.com/dynamicindex1/hvmenu/index.htm
Thanks for the code. I think I see what you're doing but I'm not sure about how to put it in my code. I'll give it a try this afternoon and let you know how it goes.
Thanks again for trying to help me.
I've managed to create a self calculating form but I'm stuck on getting the calculation amounts to round off to 2 decimal places. In the example I've pasted below, I need to make the sales tax and grand total amounts round off to 2 decimal places since it is displaying money. The other total fields I don't need to worry about since, unless the price changes, they will never be anything but a whole value. FYI, the sales tax is based on what the user selects in the state field farther up in the form.
Can someone help me?

[ September 24, 2003: Message edited by: Scott Christy ]
[ September 25, 2003: Message edited by: Eric Pascarello ]
Actually, better yet, I'd like it to base the decision to calculate sales tax based on what state they've selected from a pull down menu elsewhere in my form. How would I check to see if the state is "WI" then add 5.5% sales tax, otherwise leave the tax at 0%.
Sainudheen Mydeen - Thanks so Much!! That worked perfectly! Oone of these days I'm going to have to actually learn what the heck I'm doing with this javascript stuff. Right now I know just enough to get myself in trouble.
Ok, now that I have the calculations working, I'd like to take it one step further...I'd like to have a sales tax field that would calculate 5% sales tax on the total IF a checkbox is marked stating that they are a resident of a given State. I can handle the calculation part of it, how do I make it perform the calculation only if a checkbox is clicked?
I'm a rookie at this form calculation stuff so be kind....
I've found information on the site about adding fields but this one has an additional step. I'm trying to do an order form that calculates the totals at the end of the form.
Basically it should do this
quantity of item 1 *30 = total for item 1
quantity of item 2 *35 = total for item 2
total = total for item 1 + total for item 2
I've got everything working except for the total. If I put in a quantity of 1 for item 1 and 1 for item 2 I don't get the correct total.
Below is my code, can anyone help me figure out what I did wrong? I'm over my head here....Thanks!!!

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>temp</title>
<script language="javascript">
function calculate(form)
{
var item1 = form.item1.value;
var item2 = form.item2.value;
var item3 = form.item3.value;
var item4 = form.item4.value;
var total = form.total.value;
form.item2.value = (parseInt(item1) * 30);
form.item4.value = (parseInt(item3) * 35);
form.total.value = (item2 + item4);
}
</script>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<table border="1" cellspacing="1" width="757">
<tr>
<td width="224" align="center"><strong>Quantity</strong></td>
<td width="39" align="center"><strong>price</strong></td>
<td width="476" align="center"><strong>total</strong></td>
</tr>
<tr>
<td width="224">item1<input type="text" name="item1" size="20"
onchange="calculate(this.form)" value="0"></td>
<td width="39">$30</td>
<td width="476">total for item1 orders<input type="text" name="item2" size="20"></td>
</tr>
<tr>
<td width="224">item2<input type="text" name="item3" size="20"
onchange="calculate(this.form)" value="0"> </td>
<td width="39">$35</td>
<td width="476">total for item 2 orders<input type="text" name="item4" size="20"></td>
</tr>
<tr>
<td width="224"> </td>
<td width="39">total</td>
<td width="476"> <input type="text" name="total" size="20"></td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset"
name="B2"></p>
</form>
</body>
</html>