www.webdeveloper.com
Results 1 to 3 of 3

Thread: Display Element in an Array

  1. #1
    Join Date
    Mar 2010
    Location
    Canada
    Posts
    81

    Display Element in an Array

    I have an array of string.
    I would like to display it onto the page but the message is too long so I would like to break it up and put it on 2 lines.

    Code:
    var txtMsg = [
    	"First text",
    	"Second text",
    	"Third text",
    	"Very long text here, blah, blah, blah, blah, blah"
    ];
    Is this even possible??


    I was thinking something like this but it doesn't work.
    Code:
    var txtMsg = [
    	"First text",
    	"Second text",
    	"Third text",
    	"Very long text, blah" + '<br />' + "blah, blah, blah, blah"
    ];
    
    document.writeln(txtMsg(3));

  2. #2
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    bud, you are using the wrong set of brackets when you access txtMsg.

  3. #3
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    448
    WyCnet is right. Also you could learn a bit more about js arrays here. http://www.w3schools.com/js/js_obj_array.asp

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