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 5 of 5

Thread: Simple Array

  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Array

    Im new to JavaScript so take it steady, i have an array:

    <script type="text/javascript">

    var colOne [0] = new Array("Copyright", "Council - spending plans - consultation", "Data protection");
    var colTwo [1] = new Array("Digital Region", "Freedom of information", "Libraries - online information resources");
    var colThree [2] = new Array("Our standards", "Test"};


    document.write(colOne[0]);


    </script>

    anyone can tell why it does not work?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    "Test"};


    Code:
    var colOne = new Array("Copyright", "Council - spending plans - consultation", "Data protection");
    var colTwo = new Array("Digital Region", "Freedom of information", "Libraries - online information resources");
    var colThree = new Array("Our standards", "Test");
    
    document.write(colOne[1]);

    "How do you get your best midfielders to play together? Capello, unlike his successor, has the answer." - Football commentator

  • #3
    New Coder
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    got it working


    var colOne = new Array("Copyright", "Council - spending plans - consultation", "Data protection");
    var colTwo = new Array("Digital Region", "Freedom of information", "Libraries - online information resources");
    var colThree = new Array("Our standards", "Test");


    document.write(colOne);
    Last edited by swfc4lyf; 12-09-2010 at 09:56 AM.

  • #4
    New Coder
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script type="text/javascript">

    var colOne = new Array("<li>Copyright</li>", "<li>Council - spending plans - consultation</li>", "<li>Data protection</li>");
    var colTwo = new Array("<li>Digital Region</li>", "<li>Freedom of information</li>", "<li>Libraries - online information resources</li>");
    var colThree = new Array("<li>Our standards</li>", "<li>Test</li>");


    //document.write(colOne);
    //document.write(colTwo);
    //document.write(colThree);
    for (i = 0; i < 3; i++)
    { document.write(colOne[i]);
    if (i < 3)
    document.write("");
    }



    </script>

    got this at the moment....

    want it to output the other two arrays at the side of the current one so it looks like they are in 3 columns.

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,026
    Thanks
    36
    Thanked 494 Times in 488 Posts
    If you are happy with your query, close the thread at both places;
    See: http://www.webdeveloper.com/forum/sh...d.php?t=239569


  •  

    Posting Permissions

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