...

View Full Version : need some help with printing array elements



Christech4000
12-22-2007, 07:24 PM
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>>


<!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>>>


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];
...

Arty Effem
12-23-2007, 01:48 AM
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').

BarrMan
12-23-2007, 08:46 AM
leader2{5] = leader2[4] / leader2[1];

Christech4000
12-23-2007, 04:51 PM
thanks guys i will try what pointed put ... thank you again

Christech4000
12-23-2007, 04:55 PM
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....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum