
Originally Posted by
susie123
Thank you again Boogyman. Two questions for you:
1) How come I canīt show "personnel [0]" as the first column? Why does it have to come last?
because you have declared it last

Originally Posted by
susie123
2) How can I make equal space between the names/ages/addresses ie align them?
now you are getting into the realm of changing the way you create the array. the way you have changed / called the array, it can be very easy to confuse what is what, like you did originally with the personnel[3]. if you create a multi-dimensional array and then loop thru using better key's you would probably have an easier time accomplishing everything
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title> Multi-Dimensional Arrays</title>
<style type="text/css">
div#personnel {margin: 0 auto; width: 50%;}
div#personnel p {width: 100%; margin: .5em}
div#personnel p span{width:33%}
</style>
<script type="text/javascript">
var personnel = array(
"0" => array(
"Name:" => "Nathalay",
"Age:" => "8",
"Location" => "Cuenca",
),
"1" => array(
"Name:" => "David",
"Age:" => "31",
"Location" => "Essex",
),
"2" => array(
"Name:" => "Marlon",
"Age:" => "38",
"Location" => "Barcelona",
),
etcetc
);
</script>
</head>
<body>
<script type="text/javascript">
document.write('<div id="personnel">');
document.write("<p>Name:
<span>" +personnel[0]['name']+ "</span>
<span>" +personnel[1]['name']+ "</span>
<span>" +personnel[2]['name']+ "</span>
</p>");
document.write("<p>Age:
<span>" +personnel[0]['age']+ "</span>
<span>" +personnel[1]['age']+ "</span>
<span>" +personnel[2]['age']+ "</span>
</p>");
document.write("<p>Location:
<span>" +personnel[0]['location']+ "</span>
<span>" +personnel[1]['location']+ "</span>
<span>" +personnel[2]['location']+ "</span>
</p>");
document.write("</div>");
</script>
Bookmarks