• 0

multi dimensinal array


Question

so far nothing out of my new book works I am stryggling wiht getting a multi dimensinal array to work here is the code

 

<script language=?JavaScript? type=?text/javascript?>
var personnel = new Array();
personnel[0] = new Array();
personnel[0][0] = ?Name0?;
personnel[0][1] = ?Age0?;
personnel[0][2] = ?Address0?;
personnel[1] = new Array();
personnel[1][0] = ?Name1?;
personnel[1][1] = ?Age1?;
personnel[1][2] = ?Address1?;
personnel[2] = new Array();
personnel[2][0] = ?Name2?;
personnel[2][1] = ?Age2?;
personnel[2][2] = ?Address2?;
document.write(?Name : ? + personnel[1][0] + ?<BR>?);
document.write(?Age : ? + personnel[1][1] + ?<BR>?);
document.write(?Address : ? + personnel[1][2]);
</script>
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Works for me. Here is my cleaned up version:

<script language="JavaScript" type="text/javascript">
var personnel = [["Name0", "Age0", "Address0"],
		 ["Name1", "Age1", "Address1"],
		 ["Name2", "Age2", "Address2"]]
document.write("Name : " + personnel[1][0] + "<BR>");
document.write("Age : " + personnel[1][1] + "<BR>");
document.write("Address : " + personnel[1][2]);
</script>

I did notice something odd about the quotes when I did copy'n'paste. Check your character set to make sure you are using the correct double quote (").

Link to comment
Share on other sites

  • 0

The code you posted has curly quotes, not standard quote characters; this is common when copying code out of ebooks and programs like Microsoft Word.

 

edit: opps, didn't notice Top Qat above already mentioned that.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.