Jump to content

[SOLVED] function not working???


twilitegxa

Recommended Posts

Can anyone tell me why this script isn't working? The calcGroupDiscount function isn't working for some reason.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Central Valley Snowboarding</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="js_styles.css" type="text/css" />
</head>
<body>
<h1>Central Valley Snowboarding</h1>
<h2>Group Reservations</h2>
<form action="FormProcessor.html" method="get" enctype="application/x-www-form-urlencoded">
<h3>Snowboarding Date</h3>
<p><input type="text" name="reservationDate" />
<a href="" onclick="displayCalendar()">Select Date</a></p>
<h3>Group Leader</h3>
<table border="0">
<tr valign="top">
<td>Last Name<br />
    <input type="text" name="leaderLastName" size="50" /><br />
    First Name<br />
    <input type="text" name="leaderFirstName" size="50" /><br />
    Telephone<br />
    <input type="text" name="leaderTelephone" size="50" /><br />
    Address<br />
    <input type="text" name="leaderAddress" size="50" /><br />
    City, State, Zip<br />
    <input type="text" name="leaderCity" size="34"  />
    <input type="text" name="leaderState" size="2" maxlength="2" />
    <input type="text" name="leaderZip" size="5" maxlength="5" /></td>
</tr></table>
<script type="text/javascript">

//get date
var dateObject = new Date();
var month = dateObject.getMonth();
var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var dateToday = monthArray[month] + " " + dateObject.getDate() + "," + dateObject.getFullYear();
document.forms[0].reservationDate.value = dateToday;

//calculate group discount
function calcGroupDiscount(groupsize) {
var dailyRate = 49;
if (groupSize > 5 && groupSize < 10)
	dailyRate = 49 / 1.1;
else if (groupSize > 10 && groupSize < 25)
	dailyRate = 49 / 1.2;
else if (groupSize > 24)
	dailyRate = 49 / 1.25;
var groupRate = groupSize * dailyRate;
document.forms[0].discount.value = groupRate.toFixed(2);
}
</script>
<h3>Group Discounts</h3>
<ul>
<li>Daily Rate: $49</li>
<li>5-10 snowboarders: 10% discount</li>
<li>11-24 snowboarders: 20% discount</li>
<li>25+ snowboarders: 25% discount</li>
</ul>
<p>How many snowboarders are in your group? <input type="text" size="5" value="0" onchange="calcGroupDiscount(this.value)">
<br />
Your group rate is: $<input type="text" name="discount" size="60" value="0" readonly="readonly" style="border: none" /></p>
<p><input type="submit" value="Submit Group Reservation" /><input type="reset" value="Reset" /></p>
</form>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.