smootherkat
11-03-2008, 06:51 PM
My scripts are not working .
The calendar is not showing up
The calulator is not working
and the add camper is not right.
I am new to javascript and I am in need of some expert help
Thanks :eek:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Adirondacks Camping Experiences</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>Campsite Reservations</h1>
<hr />
<form action="FormProcessor.html" method="get" enctype="application/x-www-form-urlencoded">
<h3>Start Date</h3>
<p><input type="text" name="reservationDate" onclick="displayCalendar()" />
<a href=" "onclick="displayCalendar()"> SelectDate </a></p>
<h3>Number of Nights</h3>
<p><input type="text" name="nights" id="nights" size="3" /> <br />
Your total cost is $<input type="text" name="cost" id="cost" size="5" value="0" readonly="readonly" /> </p>
<h3>Responsible Person</h3>
<table border="0">
<tr valign="top">
<td>Last name<br />
<input type="text" name="mainLastName" size="50" /><br />
First name<br />
<input type="text" name="mainFirstName" size="50" /><br />
Telephone<br />
<input type="text" name="mainTelephone" size="50" /><br />
</td>
</tr>
</table>
<script type="text/javascript">
/* <![CDATA[ */
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;
function displayCalendar() {
calendarWin = window.open("", "CalWindow",
"status=no,resizable=yes,width=400,height=320,left=200,top=200");
calendarWin.focus();
calendarWin.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head><title>Adirondacks Camping Experiences</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>");
if (wichMonth == -1)
dateObject.setMonth(dateObject.getMonth() -1);
else if (whichMonth == 1)
dateObject.setMonth(dateObject.getMonth() +1);
var month = dateObject.getMonth();
calendarWin.document.write("<tr>< colspan='2'><a herf=''
onclick='self.opener.displayCalendar(-1) ;return false'>
Previous</a></td>< colspan='3 align='center'><storng>"
+ monthArray[month] + " " + dateObject.getFullYear()
+"</storng></td>< colspan='2' align='right'><a
href=''onclick='self.opener.displayCalendar (1);return false'>
Next</a></td></tr>");
}
calendarWin.document.write("<tr align='center'><td>Sun</td><td>Mon</td><td>Tue</td>
<td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr>");
documentWin.write("<tr align='center'>");
dateObject.setDate(1);
var daysOfWeek = dateObject.getDays();
for (var i=0; i<daysOfWeek; ++i) {
calendarWin.document.write("<td> </td>");
}
var daysWithDates = 7 - daysOfWeek;
var dateCounter = 1;
for(var i=0; i<daysWithDates; ++i) {
var curDate = monthArray[month] + " " + dateCounter + ","
+dateObject.getFullYear();
calendarWin.document.write("<td><a href='' onclick='self.opener.document.forms[0]
.resevationDate.value=\""
+ curDate + "\";self.close()'>" + dateCounter + "</a></td>");
++dateCounter;
}
var numDays =0;
// January, March, May, July, August, October, December
if (month == 0 || month == 2 || month == 4 || month == 6 ||
month == 7 || month == 9 || month == 11 )
numDay =31;
// February
else if (month == 1)
numDays == 28;
// April, June, September, November
else if (month == 3 || month == 5 || month == 8 || month == 10)
numDays =30;
for (var rowCounter = 0; rowCounter < 5; ++rowCounter) {
var weekDayCounter = 0;
calendarWin.document.write("<tr align='center'>");
while (weekDayCounter < 7) {
var curDate = monthArray[month] + " " + dateCounter + ","
+ dateObject.getFullYear();
if (dateCounter <= numDays)
caldedarWin.document.write("<td><a href=''
onclick='self.opener.document.forms[0].
reservationDate.value=\""
+ curDate + "\";self.close()'>" + dateCounter + "</a></td>");
else calendarWin.document.write("<td> :</td>");
++weekDayCounter;
++dateCounter:
calendarWin.document.write("</tr>");
calendarWin.document.write("</table></body></html>");
calendarWin.document.write.close();
}
function calcCost(nights) {
var nightcost = night * 19;
document.form[0].cost.value = nightRate;
Var contactList =new Object();
function contcat(){
this.lastName="";
this. firstName="";
function addcontact() {
var newcontact = 0;
for (contact in contactList) {
++newContact;
}
if (document.forms[0].lastName.value == "" || document.forms[0].firstName.value == "")
window.alert("You must enter the Contact's first and last names.");
else {
contactList["contact" + newContact] = new Contact ();
contactList["contact" + newContact].lastName = document.forms[0].lastName.value;
contactList["contact" + newContact].firstName = document.forms[0].firstName.value;
var createContact = new Option();
createContact.value = contactList["contact" + newContact].lastName + ", " + contactList
["contact" + newContact].firstName;
createContact.text = contactList["contact" + newContact].lastName + ", " + contactList
["contact" + newContact].firstName;
document.forms[0].contacts.options[newContact] = createContact;
}
}
//}
/* ]]> */
</script>
<h3>Campers</h3>
<p><input type="button" value="Add Camper" onclick="addCamper()" />
</p>
<table border="0">
<tr>
<td>
<select name="contacts" multiple="multiple" size="6" style="width: 150px"
onclick="contactList['contact' + this.selectedIndex].getContacts();">
<option value="contacts">Campers</option>
</select>
</td>
<td>
Last name<br />
<input type="text" name="lastname" size="50" /><br />
First name<br />
<input type="text" name="firstname" size="50" /><br />
</td>
</tr>
</table>
<br /><br /><br />
<p><input type="submit" value="Submit Camping Reservation" /></p>
</form>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10-blue"
alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
</p>
</body>
</html>
The calendar is not showing up
The calulator is not working
and the add camper is not right.
I am new to javascript and I am in need of some expert help
Thanks :eek:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Adirondacks Camping Experiences</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>Campsite Reservations</h1>
<hr />
<form action="FormProcessor.html" method="get" enctype="application/x-www-form-urlencoded">
<h3>Start Date</h3>
<p><input type="text" name="reservationDate" onclick="displayCalendar()" />
<a href=" "onclick="displayCalendar()"> SelectDate </a></p>
<h3>Number of Nights</h3>
<p><input type="text" name="nights" id="nights" size="3" /> <br />
Your total cost is $<input type="text" name="cost" id="cost" size="5" value="0" readonly="readonly" /> </p>
<h3>Responsible Person</h3>
<table border="0">
<tr valign="top">
<td>Last name<br />
<input type="text" name="mainLastName" size="50" /><br />
First name<br />
<input type="text" name="mainFirstName" size="50" /><br />
Telephone<br />
<input type="text" name="mainTelephone" size="50" /><br />
</td>
</tr>
</table>
<script type="text/javascript">
/* <![CDATA[ */
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;
function displayCalendar() {
calendarWin = window.open("", "CalWindow",
"status=no,resizable=yes,width=400,height=320,left=200,top=200");
calendarWin.focus();
calendarWin.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head><title>Adirondacks Camping Experiences</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>");
if (wichMonth == -1)
dateObject.setMonth(dateObject.getMonth() -1);
else if (whichMonth == 1)
dateObject.setMonth(dateObject.getMonth() +1);
var month = dateObject.getMonth();
calendarWin.document.write("<tr>< colspan='2'><a herf=''
onclick='self.opener.displayCalendar(-1) ;return false'>
Previous</a></td>< colspan='3 align='center'><storng>"
+ monthArray[month] + " " + dateObject.getFullYear()
+"</storng></td>< colspan='2' align='right'><a
href=''onclick='self.opener.displayCalendar (1);return false'>
Next</a></td></tr>");
}
calendarWin.document.write("<tr align='center'><td>Sun</td><td>Mon</td><td>Tue</td>
<td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr>");
documentWin.write("<tr align='center'>");
dateObject.setDate(1);
var daysOfWeek = dateObject.getDays();
for (var i=0; i<daysOfWeek; ++i) {
calendarWin.document.write("<td> </td>");
}
var daysWithDates = 7 - daysOfWeek;
var dateCounter = 1;
for(var i=0; i<daysWithDates; ++i) {
var curDate = monthArray[month] + " " + dateCounter + ","
+dateObject.getFullYear();
calendarWin.document.write("<td><a href='' onclick='self.opener.document.forms[0]
.resevationDate.value=\""
+ curDate + "\";self.close()'>" + dateCounter + "</a></td>");
++dateCounter;
}
var numDays =0;
// January, March, May, July, August, October, December
if (month == 0 || month == 2 || month == 4 || month == 6 ||
month == 7 || month == 9 || month == 11 )
numDay =31;
// February
else if (month == 1)
numDays == 28;
// April, June, September, November
else if (month == 3 || month == 5 || month == 8 || month == 10)
numDays =30;
for (var rowCounter = 0; rowCounter < 5; ++rowCounter) {
var weekDayCounter = 0;
calendarWin.document.write("<tr align='center'>");
while (weekDayCounter < 7) {
var curDate = monthArray[month] + " " + dateCounter + ","
+ dateObject.getFullYear();
if (dateCounter <= numDays)
caldedarWin.document.write("<td><a href=''
onclick='self.opener.document.forms[0].
reservationDate.value=\""
+ curDate + "\";self.close()'>" + dateCounter + "</a></td>");
else calendarWin.document.write("<td> :</td>");
++weekDayCounter;
++dateCounter:
calendarWin.document.write("</tr>");
calendarWin.document.write("</table></body></html>");
calendarWin.document.write.close();
}
function calcCost(nights) {
var nightcost = night * 19;
document.form[0].cost.value = nightRate;
Var contactList =new Object();
function contcat(){
this.lastName="";
this. firstName="";
function addcontact() {
var newcontact = 0;
for (contact in contactList) {
++newContact;
}
if (document.forms[0].lastName.value == "" || document.forms[0].firstName.value == "")
window.alert("You must enter the Contact's first and last names.");
else {
contactList["contact" + newContact] = new Contact ();
contactList["contact" + newContact].lastName = document.forms[0].lastName.value;
contactList["contact" + newContact].firstName = document.forms[0].firstName.value;
var createContact = new Option();
createContact.value = contactList["contact" + newContact].lastName + ", " + contactList
["contact" + newContact].firstName;
createContact.text = contactList["contact" + newContact].lastName + ", " + contactList
["contact" + newContact].firstName;
document.forms[0].contacts.options[newContact] = createContact;
}
}
//}
/* ]]> */
</script>
<h3>Campers</h3>
<p><input type="button" value="Add Camper" onclick="addCamper()" />
</p>
<table border="0">
<tr>
<td>
<select name="contacts" multiple="multiple" size="6" style="width: 150px"
onclick="contactList['contact' + this.selectedIndex].getContacts();">
<option value="contacts">Campers</option>
</select>
</td>
<td>
Last name<br />
<input type="text" name="lastname" size="50" /><br />
First name<br />
<input type="text" name="firstname" size="50" /><br />
</td>
</tr>
</table>
<br /><br /><br />
<p><input type="submit" value="Submit Camping Reservation" /></p>
</form>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10-blue"
alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
</p>
</body>
</html>