• 01-17-2013, 04:53 AM
ISuckatJAVA
<?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">
<!--
New Perspectives on JavaScript, 2nd Edition
Tutorial 3
Case Problem 1

The Lighthouse
Author: Franco Ferraiolo
Date: 1/16/13

Filename: clist.htm
Supporting files: lhouse.css, list.js, logo.jpg

-->
<title>The Lighthouse</title>

<body>

<script type"text/javascript" src"list.js"></script>
<script type="text/javascript">
function amountTotal() { // return sum of values to amount array

total=0;

for(var i=0; i<amount.length; i++) { // set variable to 0
total+=amount[i];
}
}
</script>

<body>

<div id="title">
<img src="logo.jpg" alt="The Lighthouse" />
The Lighthouse<br />
543 Oak Street<br />
Delphi, KY &nbsp;&nbsp;89011<br/>
(270) 555-7511
</div>
<div id = data_list>
<script type = text/javascript> // set up variables of rows and cellspaces
<script type = amountTotal(0)>
Var Total
Total = #0
<table border=’1' rules=’rows’ cellspacing=’0'>
<tr><th>Date</th><th>Amount</th><th>First Name</th>

for i=0; i < amount.length; i++ { // create a loop in counter of variable starting at 0 and increase of 1 increments
if i%2==0 document.write <tr>
else document.write <tr class= "yellowrow">
</tr>

<td> + date[i] + </td>
<td class = ’amt’>+amount[i]+</td>
<td> + firstName[i] + </td>
<td> + lastName[i] + </td>
<td>
street[i] + <br />
city[i] + state[i] + zip[i])
</td>
</tr>
}
</table>
</script>

</div>

<div id=totals>
<script type=text/javascript>
<table border=’1' cellspacing=’1'>
<tr><th id=’sumTitle’ colspan=’2'>Summary</th></tr>
<tr><th>Contributors</th>
<td> + amount.length + </td></tr>
<tr><th>Amount</th>
<td> \$ + amountTotal() + </td></tr>
</table>
</script>

</div>

</body>
</html>

</body>
</html>

can you help me fix this pleaseeee
• 01-17-2013, 07:14 AM
Hard to fix something if you don't tell us a) what it currently does and b) what it's supposed to do. Also you should use code formatting:

Code:

`<html> [...]`
• 01-17-2013, 07:25 AM
felgall
To start with you have multiple html and body tags - you should only have one of each of those.
• 01-17-2013, 07:52 AM
Philip M
I see a lot of errors.

<script type = amountTotal(0)>
Var Total
Total = #0

Plus HTML and Javascript mixed up together haphazardly.

document.write() is in effect obsolete. document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.

You certainly say that you suck at Java. You seem to have problems with Javascript as well. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

BTW, when posting here please help us to help you by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.