Error occurs when clicking submit or remove last bid, and the error refers to addBid() and removeBid(), respectively. My variable are global in the .js file, and I am exhausted, frustrated, and unable to see the issue.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Auction Log</title>
<script src="modernizr-1.5.js"></script>
<link href="ahstyles.css" rel="stylesheet" type="text/css" />
<script src="bids.js" type="text/javascript"></script>
</head>
<body>
<form name="bidForm" id="bidForm">
<header>
<img src="logo.jpg" alt="Schmitt Auction Haus" />
<nav class="horizontal">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Auctions</a></li>
<li><a href="#">Features</a></li>
<li><a href="#">Schedule</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</nav>
</header>
<section id="intro">
<h1>Silent Auction</h1>
<h2>Tawney Farm</h2>
<table id="summarytable">
<tr>
<th>Lot #121</th>
<td>TurfTuff Lawn Tractor X24 (2015)</td>
</tr>
<tr>
<th>Latest Bid</th>
<td>
<input id="latestBid" name="latestBid" readonly="readonly" />
</td>
</tr>
<tr>
<th>Bidding Ends</th>
<td>15:00</td>
</tr>
</table>
<table id="newbidtable">
<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>
</section>
<section id="bidHistory">
<h1>Bid History</h1>
<textarea id="bidList" name="bidList"></textarea>
</section>
<footer>
<address>
Schmitt AuctionHaus ·
3401 Rural Route 4 ·
Fenbrook, IN 38012
</address>
</footer>
</form>
</body>
</html>
and then the .js file
var bids = [];
var bidders = [];
var bidTime = [];
function writeBid() {
var historyText = "";
for (var i =0; i < bids.length; i++) {
historyText += bidTime[i] + " " + bids[i]+ "(" +bidders[i]+ ")" + n\;
}
document.bidForm.bidList.value += historyText;
document.bidForm.latestBid.value = bidders[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();
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var timeText = "[" + hours + ":" + minutes + ":" + seconds + "]";
bidTime.unshift(timeText);
writeBid();
}
function removeBid() {
bidders.shift();
bids.shift();
bidTime.shift();
writeBid();
}