Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2013, 04:53 AM   PM User | #1
ISuckatJAVA
New to the CF scene

 
Join Date: Jan 2013
Location: Philly
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ISuckatJAVA is an unknown quantity at this point
Exclamation Please help me with this code

<?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>
<link href="lhouse.css" rel="stylesheet" type="text/css" />
</head>

<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];
}
return total;
}
</script>
</head>

<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>
<th>Last Name</th><th>Address</th></tr>

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
ISuckatJAVA is offline   Reply With Quote
Old 01-17-2013, 07:14 AM   PM User | #2
Airblader
Regular Coder

 
Join Date: Jan 2013
Location: Germany
Posts: 348
Thanks: 3
Thanked 43 Times in 43 Posts
Airblader can only hope to improve
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> [...]
Airblader is offline   Reply With Quote
Old 01-17-2013, 07:25 AM   PM User | #3
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
To start with you have multiple html and body tags - you should only have one of each of those.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 01-17-2013, 07:52 AM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 01-17-2013 at 07:55 AM..
Philip M is offline   Reply With Quote
Reply

Bookmarks

Tags
need help!!!!!!

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 AM.


Advertisement
Log in to turn off these ads.