Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Location
    canada
    Posts
    131
    Thanks
    51
    Thanked 0 Times in 0 Posts

    Smile Javascript coding problems - program not work

    Hello all out there I am going to post this in 2 separate views.

    I am working on an assignment from this link

    http://books.google.ca/books?id=aG_T2aD ... MonthCell()&source=bl&ots=EJXyGF-tbI&sig=vbgqgua2uSaL6DWp0Rx_BYoZ0z8&hl=en&ei=9C7gTLmiAYaXnAeywLWRDw&sa=X&oi=book_result&ct=result&re snum=1&ved=0CBcQ6AEwAA#v=onepage&q=writeMonthCell()&f=false

    if u scroll down to case 1
    is what I am working on

    included in the case are 2 other files as to the one i have to work on

    i used all the proper steps and instructions and i think I have the correcting coding for my form

    however my program still does not work

    here is the exact code i am using
    let me know if anyone sees any errors, as I am convinced i have it correct?

    Here is my code:

    <html>
    <head>
    <!--
    New Perspectives on JavaScript
    Tutorial 3
    Case Problem 1

    The Lighthouse
    Author: John Res
    Date: November 14 2010

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

    -->
    <title>The Lighthouse</title>
    <link href="lhouse.css" rel="stylesheet" type="text/css" />
    <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/>
    (542) 555-7511
    </div>

    <div id="data_list">
    <script type=”text/javascript”> // set up variables of rows and cellspaces
    document.write(“<table border=’1′ rules=’rows’ cellspacing=’0′>”);
    document.write(“<tr><th>Date</th><th>Amount</th><th>First Name</th>”);
    document.write(“<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’>”); // have every row with a yellow background use a loop

    document.write(“<td>”+date[i]+”</td>”);
    document.write(“<td class=’amt’>”+amount[i]+”</td>”); // have values of the dates
    document.write(“<td>”+firstName[i]+”</td>”);
    document.write(“<td>”+lastName[i]+”</td>”);
    document.write(“<td>”);
    document.write(street[i]+”<br />”);
    document.write(city[i]+”, “+state[i]+” “+zip[i]); // zip arrays for address
    document.write(“</td>”);
    document.write(“</tr>”);
    }
    document.write(“</table>”);
    </script>

    </div>

    <div id="totals">
    <script type=”text/javascript”> // use script elements in HTML
    document.write(“<table border=’1′ cellspacing=’1′>”);
    document.write(“<tr><th id=’sumTitle’ colspan=’2′>Summary</th></tr>”);
    document.write(“<tr><th>Contributors</th>”);
    document.write(“<td>”+amount.length+”</td></tr>”);
    document.write(“<tr><th>Amount</th>”);
    document.write(“<td>$”+amountTotal()+”</td></tr>”);
    document.write(“</table>”);
    </script>

    </div>

    </body>
    </html>

    thanks everyone
    Last edited by worldtraveller; 11-15-2010 at 11:10 AM.

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by worldtraveller View Post

    here is the exact code i am using
    Your code contains word-processing characters. You must create your code using a text editor or convert it to plain text.

  • Users who have thanked Logic Ali for this post:

    worldtraveller (11-15-2010)

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Location
    canada
    Posts
    131
    Thanks
    51
    Thanked 0 Times in 0 Posts
    my code is word processing? how so

    as i did the coding all on textwrangler which is totally for javascript etc?


    Does all my lines seem wrong of what i typed? bad format? or what exactly did i go wrong?
    thanks

  • #4
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by worldtraveller View Post
    my code is word processing? how so

    as i did the coding all on textwrangler which is totally for javascript etc?


    Does all my lines seem wrong of what i typed? bad format? or what exactly did i go wrong?
    thanks
    The double and single quote characters ( “ ” ’ ) are incorrect, they should be " and ' respectively. I'm not familiar with that editor, but it must have a way of fixing that.

  • Users who have thanked Logic Ali for this post:

    worldtraveller (11-15-2010)

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,078
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You must have copied it from somewhere using copy and paste.

    <script type=”text/javascript”> will simply not function.

    When posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.


    It is your responsibility to die() if necessary….. - PHP Manual

  • Users who have thanked Philip M for this post:

    worldtraveller (11-15-2010)

  • #6
    Regular Coder
    Join Date
    Nov 2010
    Location
    canada
    Posts
    131
    Thanks
    51
    Thanked 0 Times in 0 Posts
    Textwrangler is the text editor for MAC computers.

    For all my quotations

    is it just my " and ' that seems to be wrong

    or are all my actual structures incorrect as well?

    give me an example of one line, as now i am so confused.

    thanks

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,078
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    There are many instances of incorrect pattern quotes.

    document.write(“<td>”+date[i]+”</td>”);

    Put these right, then test you code again using your error console. You should not look to this forum just to identify syntax errors. Firebug will do that for you.

  • Users who have thanked Philip M for this post:

    worldtraveller (11-17-2010)

  • #8
    Regular Coder
    Join Date
    Nov 2010
    Location
    canada
    Posts
    131
    Thanks
    51
    Thanked 0 Times in 0 Posts
    I am going over my notes and so far I am not successful on this. Nothing is working it seems.

    What would be the proper way to type out this small portion of code such as for.

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

    thanks all.

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,078
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    One more time:-

    When posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.

    You do not have any array named amount, so there is nothing to add up.

    Passengers hit by cancelled trains. - Guildford News And Mail

  • Users who have thanked Philip M for this post:

    worldtraveller (11-16-2010)

  • #10
    Regular Coder
    Join Date
    Nov 2010
    Location
    canada
    Posts
    131
    Thanks
    51
    Thanked 0 Times in 0 Posts
    ok all I went over my assignment again and worked on all my arrays and loops

    now i made the program worse then it was before

    here is all my coding now

    i messed it all up
    Here is all my code


    Code:
    
    <html>
    <head>
    <!-- 
    New Perspectives on JavaScript
    Tutorial 3
    Case Problem 1
    
    The Lighthouse
    Author: Joh
    Date: November 14 2010
    
    Filename: clist.htm
    Supporting files: lhouse.css, list.js, logo.jpg
    
    -->
    <title>The Lighthouse</title>
    <link href="lhouse.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="list.js"></script>
    
    <script type="text/javascript">
    
    function amountTotal() { 
    
    
    <script type="text/javascript">
    
    	function amountTotal() {            
    	var amountTotal=0;
    	var	total=0;
    	
    	for ( amountTotal=0;amountTotal<=0;i++)
    	var<=0; var=amountTotal+total )	
      	{
    	document.write(i+ <"/br>" );
    	}
    	</script>
    
    
    
    </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/>
    (542) 555-7511
    </div>
    
    <div id="data_list">
    
    <script type+"text/javascript" // set up variables of rows and cellspaces
    document.write("<table border='1' rules='rows' cellspacing='0'>");
    <tr>
    document.write("<th>Date</th><th>Amount</th><th>First Name</th>");
    document.write("<th>Last Name</th><th>Address</th>"); 
    
    
    <script language="javascript">
    
    for (counter=0; amountarray<=; counter->amount array+1);
    {
    document.write("<tr><td>"+amountarray+"</td><td>"
    +(counter+1)+"</td></tr>");
    }
    </script>
    </table>
    
    else document.write("<tr class=’yellowrow’>”); 
    <td>date</td>
    document.write("<td>”+date+”</td>”);
    document.write("<td class='amt'>”+amount[i]+"</td>"); 
    document.write("<td>”+firstName[i]+”</td>”);
    document.write("<td>”+lastName[i]+”</td>”);
    document.write("<td>”);
    document.write(street[i]+"<br />”);
    document.write(city[i]+", “+state[i]+” “+zip[i]); 
    document.write("</td>”);
    document.write("</tr>”);
    }
    document.write(“</table>”);
    </script>
    
    </div>
    
    <div id="totals">
    <script type="text/javascript”>	
    document.write("<table border=’1′ cellspacing=’1′>”);
    document.write"<tr><th> id=’sumTitle’ colspan=’2′>Summary</th></tr>”);
    document.write("<th>Contributors</th>”);
    
    document.write("<td>contributions</td>");
    document.write("<td><tr>”+amount.length+”</td></tr>”);
    document.write("<th>Amount</th>”);
    document.write("<tr><td>$”+amountTotal()+”</td></tr>”);
    document.write("</table>”);
    </script>
    
    </div>
    
    </body>
    </html>
    
    thanks all for taking the time to look it all over
    Last edited by worldtraveller; 11-17-2010 at 03:27 AM. Reason: change of code

  • #11
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,078
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    There are still numerous cases of incorrect quotes in your code. Examples:-

    document.write(city[i]+", “+state[i]+” “+zip[i]);
    document.write("</td>”);
    document.write("</tr>”);
    }
    document.write(“</table>”);

    You must get rid of all of those. Use global find and replace in your editor.
    Then use your error console.
    Until you do that nothing more can be done for you.

  • Users who have thanked Philip M for this post:

    worldtraveller (11-17-2010)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •