SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: array problem

  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    array problem

    I have this code
    Code:
    var n = new array("de","en","gr");
    for (var i=0; i<n.length; i++)
    alert (n[x])
    But it does not work (array is not defined).What is wrong?
    How can I take each value of the array?
    Dimis

  2. #2
    SitePoint Zealot Amenthes's Avatar
    Join Date
    Oct 2006
    Location
    Bucharest, Romania
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript is case-sensitive. It should be Array with a capital A instead of array.
    I'm under construction | http://igstan.ro/

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    var n = new Array();
    n[0] = "de";
    n[1] = "en";
    n[2] = "gr";

    for (var i=0; i<n.length; i++) alert (n[i]);
    Last edited by th76; Oct 4, 2008 at 05:00.

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var n = ["de", "en", "gr"];
    for (var i = 0, len = n.length; i < len; i++)
        alert (n[i]);


Bookmarks

Posting Permissions

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