WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 another javascript oop question, sam conrad, October 20, 2003
     Re:another javascript oop question, Erik Arvidsson, October 20, 2003

Subject: another javascript oop question From: sam conrad Date: October 20, 2003

<script>
/* Hi guys!! i am trying to nest objects in an array, such that instead of having to code:
alert(main[2][0].text); to get the property value "B"

i can just code: alert(main[2].text); and get the same results.

I suppose this should be faily simple, but I don't understand oop well enough to know how to do it.
Any suggestions would be greatly appreciated. My simplified example code follows: Cheers!!  */
var a = [new function(){this.text="A";}, "A_etc",];
var b = [new function(){this.text="B";}, "B_etc",];
var c = [new function(){this.text="C";}, "C_etc",];
var main = [a, b, c];
// this works:
alert(main[0][0].text);
alert(main[1][0].text);
alert(main[2][0].text);
// would like to be able to code:
alert(main[0].text);
alert(main[1].text);
alert(main[2].text);
</script>




Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX