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 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2007
    Location
    Michigan
    Posts
    36
    Thanks
    27
    Thanked 0 Times in 0 Posts

    need some help with printing array elements

    I have an array that wiil not print any elements as a matter of fact when I try and print any of the elementsfrom the array the whole document disapears
    can anyone help me? the mark up>>

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>NBA Finals All-Time Scoring Leaders</title>
    <link rel="stylesheet" href="js_styles.css" type="text/css"/>
    <script src="nba.js" type="text/javascript"></script>
    
    </head>
    
    <body>
    
    <h1>NBA Finals</h1>
    
    <h2>ALL-Time Scoring Leaders</h2>
    
    <script type="text/javascript">
    
    document.write("<p><b>scored</b></p>"+leader1[0]);
    
    </script>
    
    </body>
    </html>
    and the javascript>>>

    Code:
    var leader1 = new Array();
    leader1[0] = "Rick Barry";//player name
    leader1[1] = 10;//number of games
    leader1[2] = 138;//two point baskets
    leader1[3] = 87;//free throws
    leader1[4] = leader1[2] * 2 + leader1[3];//total points
    leader1[5] =  leader1[4] / leader1[1];//average points
    
    
    var leader2 = new Array();
    leader2[0] = "Micheal Jordan";
    leader2[1] = 35;
    leader2[2] = 438;
    leader2[3] = 258;
    leader2[4] = leader2[2] * 2 + leader2[3];
    leader2{5] = leader2[4] / leader2[1];
    ...

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Christech4000 View Post
    I have an array that wiil not print any elements as a matter of fact when I try and print any of the elementsfrom the array the whole document disapears
    can anyone help me?
    There is a syntax error which the error console will describe to you. Use the console in Firefox preferably (it's under 'Tools').

  • Users who have thanked Arty Effem for this post:

    Christech4000 (12-23-2007)

  • #3
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    Code:
    leader2{5] = leader2[4] / leader2[1];

  • Users who have thanked BarrMan for this post:

    Christech4000 (12-23-2007)

  • #4
    New Coder
    Join Date
    Oct 2007
    Location
    Michigan
    Posts
    36
    Thanks
    27
    Thanked 0 Times in 0 Posts
    thanks guys i will try what pointed put ... thank you again

  • #5
    New Coder
    Join Date
    Oct 2007
    Location
    Michigan
    Posts
    36
    Thanks
    27
    Thanked 0 Times in 0 Posts
    it worked thank you so much I am working very hard at this and this helps me more than you know I was stucki and could not move forward in my book...I am getting ready for next semester in which js leads into xml and ajax so thanks....


  •  

    Posting Permissions

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