www.webdeveloper.com
Results 1 to 4 of 4

Thread: Javascript problem.

  1. #1
    Join Date
    Feb 2011
    Posts
    20

    Question Javascript problem.

    How do I get the months of the year like this:

    jan
    feb
    mar

    instead of like this:

    jan, feb, mar

    Thanks.

  2. #2
    Join Date
    Feb 2011
    Posts
    20
    Quote Originally Posted by Henrygruby View Post
    How do I get the months of the year like this:

    jan
    feb
    mar

    instead of like this:

    jan, feb, mar

    Thanks.
    var dayArray = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];

    var weekBeginning = '12 July 2010'
    var distanceArray = ["2", "4", "2", "1", "5", "4", "3"];

    var weekBeginning = '19 July 2010'
    var str = ["2", "6", "3", "1", "6", "4", "2"];

    document.write("<h1>This is a heading</h1>");
    document.write("<br />");

    for (i = 0; i <= -1; i++)
    for (j = 0; j <= -1; j++)

    {
    dayArray[i] = i;
    distanceArray[j] = j;
    }
    document.write(dayArray);
    document.write("<br />");
    document.write(distanceArray);

  3. #3
    Join Date
    Dec 2010
    Posts
    207
    Code:
    document.write(dayArray.toString().replace(/,\s*/g, '<br>'));
    Of course if you're going to want to document.write something after each day, then that's a different matter.

  4. #4
    Join Date
    Feb 2011
    Posts
    20
    Quote Originally Posted by clueful View Post
    Code:
    document.write(dayArray.toString().replace(/,\s*/g, '<br>'));
    Of course if you're going to want to document.write something after each day, then that's a different matter.
    Thanks mate, it works.

    Could you briefly explain what this piece exactly does?


    /,\s*/g,

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles