Menu
My department is having a symposium and I need to figure out how to calculate what the person is going to pay. I have the basic stuff down (check the box, and it automatically adds $10, but what I need to do now is figure out how to calculate if more than one person is coming. I have a drop-down box in another cell on the table with values from 0-6. How do I get it to calculate that x amount of people are coming, and we need to add $10 for each person? I’m racking my brain, but I just can’t figure it out.
Thanks so much.
Do you have a brief sample of the existing code to look at so that I don't have to start from scratch. Not everything on the page, just the code you have started.[/QUOTE]
var Cost, GST, PST, Grand_Total;
Cost = dollar(Cost);
Grand_Total = parseFloat(Cost);
Grand_Total = dollar(Grand_Total);
document.orderform.Total.value = "$" + Cost;
document.orderform.GrandTotal.value = "$" + Grand_Total;
}
A lot more code that I expected :eek: so I'll touch back later. ?[/QUOTE]
[CODE]
function tally()
{
Cost = 0;
if (document.orderform.Symposium.checked) { Cost = Cost + 0; }
if (document.orderform.Lunch.checked) {
Cost = Cost + 10;
var sel=document.orderform.Lunch1.options[document.orderform.Lunch1.selectedIndex].value;
Cost = Cost + (10 * parseInt(sel))
}
if (document.orderform.Poster.checked) { Cost = Cost + 0; }
if (document.orderform.Presentation.checked) { Cost = Cost + 0; }
if (document.orderform.Banquet.checked) {
Cost = Cost + 40;
var sel=document.orderform.Banquet1.options[document.orderform.Banquet1.selectedIndex].value;
Cost = Cost + (40 * parseInt(sel))
}
[/CODE]
Almost there:
Changed:
[CODE]
function tally()
{
Cost = 0;
if (document.orderform.Symposium.checked) { Cost = Cost + 0; }
if (document.orderform.Lunch.checked) {
Cost = Cost + 10;
var sel=document.orderform.Lunch1.options[document.orderform.Lunch1.selectedIndex].value;
Cost = Cost + (10 * parseInt(sel))
}
if (document.orderform.Poster.checked) { Cost = Cost + 0; }
if (document.orderform.Presentation.checked) { Cost = Cost + 0; }
if (document.orderform.Banquet.checked) {
Cost = Cost + 40;
var sel=document.orderform.Banquet1.options[document.orderform.Banquet1.selectedIndex].value;
Cost = Cost + (40 * parseInt(sel))
}
[/CODE]
Now I need to locate the <SELECT> areas to add an OnChange() event to call tally() again, I think. May need to change the way Cost is calculated to avoid adding it in more than once. Need to check this out next.[/QUOTE]
[CODE]
<select name="Lunch1" id="Lunch1" onChange="tally()">
...
and
...
<select name="Banquet1" id="Banquet1" onChange="tally()">
[/CODE]
[CODE]
<h3><em><strong>Number of Attendees </strong></em></h3>
[/CODE]
[CODE]
<h3><em><strong>Number of Additional Attendees </strong></em></h3>
[/CODE]
Two more changes and I think you're almost done. ?
[CODE]
<select name="Lunch1" id="Lunch1" onChange="tally()">
...
and
...
<select name="Banquet1" id="Banquet1" onChange="tally()">
[/CODE]
I'm not sure of your method of calculation, but I would change the column description from:
[CODE]
<h3><em><strong>Number of Attendees </strong></em></h3>
[/CODE]
to:
[CODE]
<h3><em><strong>Number of Additional Attendees </strong></em></h3>
[/CODE]
instead since you have already added $10 or $40 with the first person.
Another small suggestion: Why have selection boxes for additional attendees if there is no cost involved in the calculation? Is it just to allow for room size? :rolleyes:[/QUOTE]
It's not doing anything at all now. I'm just going to throw the computer out the window and be done with it.[/QUOTE]
Point of clarification:
Program is not working, computer is not working or you're not working?
I know of only three kinds of computer failures:
1. Hardware failure - components die.
2. Software failure - program code dies.
3. Mushware failure - coder's mind turns to mush.
The code I finished is available if you have no backups. ?[/QUOTE]
0.1.9 — BETA 5.18