webmast3r
03-12-2009, 01:46 PM
im working on this script for a project and i cant find anything wrong here. my professor told me to proofread the "historyText" line but i dont see anything.
<html>
<head>
<!--
New Perspectives on JavaScript
Tutorial 3
Case Problem 3
Schmitt AuctionHaus
Author: Brandon Niehaus
Date:
Filename: auction.htm
Supporting files: logo.jpg, styles.css
-->
<title>Auction Log</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript>
var bids = new Array();
var bidders = new Array();
var bidTime = new Array();
function writeBid() {
var historyText="";
for (var i=0; i<bids.length; i++) {
historyText +="bidTime[i]+("+bidders[i]+")\n";
}
document.bidForm.bidList.value=historyText;
document.bidForm.highBid.value=bids[0];
document.bidForm.bidId.value="";
document.bidForm.bidAmount.value="";
}
function addBid() {
bidders.unshift(document.bidForm.bidId.value);
bids.unshift(document.bidForm.bidAmount.value);
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
// add leading zeros to minutes and seconds less than 10
minutes = minutes < 10 ? "0" +minutes : minutes
seconds = seconds < 10 ? "0" +seconds : seconds;
var timeText = "["+hours+":"+minutes+":"+seconds+"]";
bidTime.unshift(timeText);
writeBid();
}
function removeBid() {
bidders.shift();
bids.shift();
bidTime.shift();
writeBid();
}
</script>
</head>
<body>
<form name="bidForm" id="bidForm">
<div id="head">
<p>
<a href="#">Home</a> <a href="#">Auctions</a>
<a href="#">Features</a> <a href="#">Schedule</a>
<a href="#">Contacts</a>
</p>
<img src="logo.jpg" alt="Schmitt Auction Haus" /></div>
<div id="intro">
<h1>Silent Auction</h1>
<h2>Tawney Farm</h2>
<table id="summarytable" border="2">
<tr>
<th>Lot #121</th>
<td>TurfTuff Lawn Tractor X24 (2003)</td>
</tr>
<tr>
<th>Current High Bid</th>
<td>
<input id="highBid" name="highBid" readonly="readonly" />
</td>
</tr>
<tr>
<th>Bidding Ends</th>
<td>15:00</td>
</tr>
</table>
<table id="newbidtable" border="2">
<tr>
<th colspan="2" id="newtitle">Enter New Bid</th>
</tr>
<tr>
<th>Bidder ID</th>
<td>
<input id="bidId" name="bidId" />
</td>
</tr>
<tr>
<th>Bid Amount</th>
<td>
<input id="bidAmount" name="bidAmount" />
</td>
</tr>
<tr>
<th id="buttons" colspan="2">
<input type="button" value="Submit" onclick="addBid()" />
<input type="button" value="Remove Last Bid" onclick="removeBid()" />
</th>
</tr>
</table>
</div>
<div id="bidHistory">
<h1>Bid History</h1>
<p>
<textarea id="bidList" name="bidList"></textarea>
</p>
</div>
<address>
Schmitt AuctionHaus ·
3401 Rural Route 4 ·
Fenbrook, IN 38012
</address>
</form>
</body>
</html>
<html>
<head>
<!--
New Perspectives on JavaScript
Tutorial 3
Case Problem 3
Schmitt AuctionHaus
Author: Brandon Niehaus
Date:
Filename: auction.htm
Supporting files: logo.jpg, styles.css
-->
<title>Auction Log</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript>
var bids = new Array();
var bidders = new Array();
var bidTime = new Array();
function writeBid() {
var historyText="";
for (var i=0; i<bids.length; i++) {
historyText +="bidTime[i]+("+bidders[i]+")\n";
}
document.bidForm.bidList.value=historyText;
document.bidForm.highBid.value=bids[0];
document.bidForm.bidId.value="";
document.bidForm.bidAmount.value="";
}
function addBid() {
bidders.unshift(document.bidForm.bidId.value);
bids.unshift(document.bidForm.bidAmount.value);
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
// add leading zeros to minutes and seconds less than 10
minutes = minutes < 10 ? "0" +minutes : minutes
seconds = seconds < 10 ? "0" +seconds : seconds;
var timeText = "["+hours+":"+minutes+":"+seconds+"]";
bidTime.unshift(timeText);
writeBid();
}
function removeBid() {
bidders.shift();
bids.shift();
bidTime.shift();
writeBid();
}
</script>
</head>
<body>
<form name="bidForm" id="bidForm">
<div id="head">
<p>
<a href="#">Home</a> <a href="#">Auctions</a>
<a href="#">Features</a> <a href="#">Schedule</a>
<a href="#">Contacts</a>
</p>
<img src="logo.jpg" alt="Schmitt Auction Haus" /></div>
<div id="intro">
<h1>Silent Auction</h1>
<h2>Tawney Farm</h2>
<table id="summarytable" border="2">
<tr>
<th>Lot #121</th>
<td>TurfTuff Lawn Tractor X24 (2003)</td>
</tr>
<tr>
<th>Current High Bid</th>
<td>
<input id="highBid" name="highBid" readonly="readonly" />
</td>
</tr>
<tr>
<th>Bidding Ends</th>
<td>15:00</td>
</tr>
</table>
<table id="newbidtable" border="2">
<tr>
<th colspan="2" id="newtitle">Enter New Bid</th>
</tr>
<tr>
<th>Bidder ID</th>
<td>
<input id="bidId" name="bidId" />
</td>
</tr>
<tr>
<th>Bid Amount</th>
<td>
<input id="bidAmount" name="bidAmount" />
</td>
</tr>
<tr>
<th id="buttons" colspan="2">
<input type="button" value="Submit" onclick="addBid()" />
<input type="button" value="Remove Last Bid" onclick="removeBid()" />
</th>
</tr>
</table>
</div>
<div id="bidHistory">
<h1>Bid History</h1>
<p>
<textarea id="bidList" name="bidList"></textarea>
</p>
</div>
<address>
Schmitt AuctionHaus ·
3401 Rural Route 4 ·
Fenbrook, IN 38012
</address>
</form>
</body>
</html>