I am new to Javascript, but am trying to do a simple calculation. I need to have the rate that is displayed by the ATHLETE option box, multiplied by the number of hours, displayed in the price box below once the button is clicked. I am very close but must be slightly off. If someone could please help it would be greatly appreciated. Reply here or email me at [email][email protected]
<html>
<title>Book The Brits Now!</title>
<head>
<SCRIPT LANGUAGE=”JAVASCRIPT”>
<!–Hide from old browsers
document.bgColor=”gold”
var athlete= new Array(0, 19, 39, 79)
function Calc(myForm) {
var athleteItem = myForm.athlete.selectedIndex
var totalPrice = athlete[athleteItem]
document.XOptions.ratea.value = format(totalPrice)
}
function Price(myForm) {
var athleteItem = myForm.athlete.selectedIndex
var hourNum = myForm.hoursa.value
var EstPrice = hourNum*athleteItem
document.ZOptions.PicExtPrice.value = format(EstPrice)
}
//–>
</SCRIPT>
</head>
<body text=”black” link=”red” vlink=”red” onload=”setTimeout(‘bancycle()’,3000)” align=”center”>
<SCRIPT LANGUAGE=”JAVASCRIPT”>
<!– Hide from old browsers
function format(valuein) {
var dollars = new String(valuein)
var Outdollars = ” “
var dollen = dollars.length
if (dollen > 3) {
while (dollen>0) {
tDollars=dollars.substring(dollen-3, dollen)
if (tDollars.length==3) {
Outdollars=”,”+tDollars+Outdollars
dollen=dollen-3;
} else {
Outdollars=tDollars+Outdollars
dollen=0
}
}
if (Outdollars.substring(0, 1)==”,”)
dollars=Outdollars.substring(1, Outdollars.length)
else
dollars=Outdollars
}
var amountOut = “$”+dollars
return amountOut
}
// — End hiding here –>
</SCRIPT>
<h1 align=”center”>Book The Brits!</H1>
<CENTER><IMG SRC=”chris.jpg”>
<CENTER><TABLE BORDER=0 WIDTH=”60%”>
<TR>
<TD COLSPAN=”3″>The Brits want to come and play for you, so fill in the form below and we will be glad to bring you a wonderful performance! The base price for a one hour performance is $99, but with the additional information you will provide below we will determine the actual cost. All prices below are based on an hourly rate.
<P><B>Optional Upgrades</B></td>
<tr>
<td><FORM NAME=”XOptions”>
<SELECT Name=”athlete” onchange=”Calc(XOptions)”>
<OPTION>Select Athlete Options
<OPTION>Basic Set-up
<OPTION>Full Light Show
<OPTION>Full Light Show with Video Screen
</SELECT>
</td>
<td>
<BR>
<SELECT Name=”embrace”>
<OPTION>Select Embrace Options
<OPTION>Basic Set-up
<OPTION>Full Light Show
<OPTION>Full Light Show with Video Screen
</SELECT>
<BR>
</td>
<td>
<SELECT Name=”coldplay”>
<OPTION>Select Coldplay Options
<OPTION>Basic Set-up
<OPTION>Full Light Show
<OPTION>Full Light Show with Video Screen
</SELECT>
</td>
</tr>
<tr>
<td><p align=”left”>Rate: <Input Type=”text” Name=”ratea” value=” “></td>
<td><p align=”left”>Rate: <Input Type=”text” Name=”ratee” value=” “></td>
<td><p align=”left”>Rate: <Input Type=”text” Name=”ratec” value=” “></td>
</tr>
<tr>
<td><p align=”left”>Hours: <Input Type=”text” Name=”hoursa” value=”3″></td>
<td><p align=”left”>Hours: <Input Type=”text” Name=”hourse” value=” “></td>
<td><p align=”left”>Hours: <Input Type=”text” Name=”hoursc” value=” “></td>
</tr>
</form>
<tr>
<td><FORM NAME=”ZOptions”>
<P>Calculated price: <INPUT type=”text” value=” ” Name=”PicExtPrice” size=7>
<P><INPUT type=”Button” value=”Price” onchange=”Price()” Name=”Arrangement”></TD>
<td>
<P>Calculated price: <INPUT type=”text” value=” ” Name=”PiecePrice” size=7>
<P><INPUT type=”Button” value=”Price” onclick=”Calc(XOptions)” Name=”Arrangement”></TD>
<td>
<P>Calculated price: <INPUT type=”text” value=” ” Name=”PiecePrice” size=7>
<P><INPUT type=”Button” value=”Price” onclick=”Calc(XOptions)” Name=”Arrangement”></TD>
</tr>
</FORM>
</TABLE></CENTER>
</body>
</html>