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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Romania
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to bind 2 or more arrays together?

    How to bind 2 or more arrays together?
    I set up the arrays like this:

    var MenuName=new Array();
    MenuName[0]=["Menu1","first.htm"];
    MenuName[1]=["Menu2","prof.htm"];
    MenuName[2]=["Menu3","myself.html"];
    MenuName[3]=["M4NoHref","","","Link"];
    MenuName[4]=["M5NoHref","","","Civil"];

    var Link=new Array();
    var Exe=new Array();

    Link[0]=["Google","http://www.google.com"];
    Link[1]=["Yahoo","http://www.yahoo.com"];

    Civil[0]=["C1","http://www.discovery.com"];
    Civil[1]=["C2","http://www.nationalgeographic.com"];


    Then I wanted to link the first one (MenuName) with the second(Link):

    for (i=0;i<MenuName.length;i++){
    if (MenuName[i][3]) { txt=MenuName[i][3] }
    //this is wrong I guess
    for (j=0;j<txt.length;j++){
    document.write('<div><table><tr><td>'
    +txt[j][0]+'</td></tr></table></div>')}

    //where txt[j][0] , for i=0 && j=0, should be "Google"


    Can someone help me with this???

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    MenuName[3]=["M4NoHref","","","Link"];

    this is a string, not an array name. using it to refer to an array won't work, because it doesn't have any connection to the array. if you want to make it work, try this:

    MenuName[3]=["M4NoHref","","",];
    MenuName[3][3] = ["Google","http://www.google.com"];
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.


  •  

    Posting Permissions

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