Good Day -
I have written a form which collects input for a fare calculation. The form
collects the following:
1) Departure or Destination Group (1,2,or 3)
2) Number of Adults
3) Number of Children aged 4 to 12
4) Number of Children under age 4
Based on this data, I need to calculate a fare as follows:
1) The base fare is $80.00, $70.00 or $60.00 per person, depending on which
Departure/Destination Group is selected. If there is more than one adult,
all adults after the first one receive a 40% discount.
2) The rate per Child 4 - 12 is one have the base fare per child.
3) Children under 4 are free.
The following is the form and the Javascript, but I cannot get it to work.
Any help or suggestions would be truly appreciated.
Mike Hagstrom
*************** *************** *************** *************** *************** *
*
<form name="quote">
<table width="500" border="2" cellspacing="2" cellpadding="2"
align="CENTER">
<tr><td>Selec t Your Group: </td><td>Key West Group <inp ut
type="Radio" name="Group" value="1"><br>L ower Keys Group <inp ut
type="Radio" name="Group" value="2"><br>M iddle/Upper Keys Group <inp ut
type="Radio" name="Group" value="3"></td></tr>
<tr><td>Numbe r of Adults: </td><td><INPUT NAME="Adults" SIZE=5
MAXLENGTH=50></td></tr>
<tr><td>Numbe r Children 4-12 yrs: </td><td><INPUT NAME="Chil412"
SIZE=5 MAXLENGTH=50></td></tr>
<tr><td>Numbe r Children Under 4 yrs: </td><td><INPUT NAME="ChilU4"
SIZE=5 MAXLENGTH=50></td></tr>
<tr><td ><input type=button value="Calculat e"
onClick="calcul ate()"></td></tr>
<tr><td>Total Passengers:</td><td><input type=text name=totalpass
size=12></td></tr>
<tr><td>Your Fare:</td><td><input type=text name=totalfare
size=12></td></tr>
</table>
</form>
<script type=text/javascript>
function calculate() {
if (document.quote .Group.value = 1)
then Var farepp = 80;
else if (document.quote .Group.value = 2)
then Var farepp = 70;
else Var farepp = 60;
var Adults = document.quote. Adults.value;
var Chil412 = document.quote. Chil412.value;
var ChilU4 = document.quote. ChilU4.value;
var totalpass = Math.pow(Adults +Chil412+ChiU4) ;
var totalfare = Math.pow((farep p*Adults)+(Chil 412*farepp/2));
document.quote. totalpass.value ="";
document.quote. totalfare.value ="";
}
</script>
I have written a form which collects input for a fare calculation. The form
collects the following:
1) Departure or Destination Group (1,2,or 3)
2) Number of Adults
3) Number of Children aged 4 to 12
4) Number of Children under age 4
Based on this data, I need to calculate a fare as follows:
1) The base fare is $80.00, $70.00 or $60.00 per person, depending on which
Departure/Destination Group is selected. If there is more than one adult,
all adults after the first one receive a 40% discount.
2) The rate per Child 4 - 12 is one have the base fare per child.
3) Children under 4 are free.
The following is the form and the Javascript, but I cannot get it to work.
Any help or suggestions would be truly appreciated.
Mike Hagstrom
*************** *************** *************** *************** *************** *
*
<form name="quote">
<table width="500" border="2" cellspacing="2" cellpadding="2"
align="CENTER">
<tr><td>Selec t Your Group: </td><td>Key West Group <inp ut
type="Radio" name="Group" value="1"><br>L ower Keys Group <inp ut
type="Radio" name="Group" value="2"><br>M iddle/Upper Keys Group <inp ut
type="Radio" name="Group" value="3"></td></tr>
<tr><td>Numbe r of Adults: </td><td><INPUT NAME="Adults" SIZE=5
MAXLENGTH=50></td></tr>
<tr><td>Numbe r Children 4-12 yrs: </td><td><INPUT NAME="Chil412"
SIZE=5 MAXLENGTH=50></td></tr>
<tr><td>Numbe r Children Under 4 yrs: </td><td><INPUT NAME="ChilU4"
SIZE=5 MAXLENGTH=50></td></tr>
<tr><td ><input type=button value="Calculat e"
onClick="calcul ate()"></td></tr>
<tr><td>Total Passengers:</td><td><input type=text name=totalpass
size=12></td></tr>
<tr><td>Your Fare:</td><td><input type=text name=totalfare
size=12></td></tr>
</table>
</form>
<script type=text/javascript>
function calculate() {
if (document.quote .Group.value = 1)
then Var farepp = 80;
else if (document.quote .Group.value = 2)
then Var farepp = 70;
else Var farepp = 60;
var Adults = document.quote. Adults.value;
var Chil412 = document.quote. Chil412.value;
var ChilU4 = document.quote. ChilU4.value;
var totalpass = Math.pow(Adults +Chil412+ChiU4) ;
var totalfare = Math.pow((farep p*Adults)+(Chil 412*farepp/2));
document.quote. totalpass.value ="";
document.quote. totalfare.value ="";
}
</script>
Comment