andynov123
11-13-2012, 04:27 PM
Can someone tell me why my window.alert wont appear when I load the page?
<?xml version="1.0" encoding="UTF-8" ?>
<!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">
<title>Congressional Races</title>
<script type="text/javascript src="votes.js"></script>
<script type ="text/javascript">
function totalVotes(){
var total = 0;
var counter=0;
var votes= = [94766, 168751, 116492, 103516, 86855];
/*
votes0[0] = 94766;
votes1[1] = 168751;
votes2[2] = 116492;
votes3[3] = 103516;
votes4[4] = 86855;
*/
for(i=0; i<=votes[counter];i++){
total = votes[i] + total;
window.alert("The total is: " + total);
}
}
</script>
<script type="text/javascript">
totalVotes();
</script>
<link href="results.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="intro">
<p><img src="logo.jpg" alt="Election Day Results" /></p>
<a href="#">Election Home Page</a>
<a href="#">President</a>
<a href="#">Senate Races</a>
<a href="#">Congressional Races</a>
<a href="#">State Senate</a>
<a href="#">State House</a>
<a href="#">Local Races</a>
<a href="#">Judicial</a>
<a href="#">Referendums</a>
</div>
<div id="results">
<h1>Congressional Races</h1>
</div>
</body>
</html>
<?xml version="1.0" encoding="UTF-8" ?>
<!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">
<title>Congressional Races</title>
<script type="text/javascript src="votes.js"></script>
<script type ="text/javascript">
function totalVotes(){
var total = 0;
var counter=0;
var votes= = [94766, 168751, 116492, 103516, 86855];
/*
votes0[0] = 94766;
votes1[1] = 168751;
votes2[2] = 116492;
votes3[3] = 103516;
votes4[4] = 86855;
*/
for(i=0; i<=votes[counter];i++){
total = votes[i] + total;
window.alert("The total is: " + total);
}
}
</script>
<script type="text/javascript">
totalVotes();
</script>
<link href="results.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="intro">
<p><img src="logo.jpg" alt="Election Day Results" /></p>
<a href="#">Election Home Page</a>
<a href="#">President</a>
<a href="#">Senate Races</a>
<a href="#">Congressional Races</a>
<a href="#">State Senate</a>
<a href="#">State House</a>
<a href="#">Local Races</a>
<a href="#">Judicial</a>
<a href="#">Referendums</a>
</div>
<div id="results">
<h1>Congressional Races</h1>
</div>
</body>
</html>