SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post How to print the value of my variable dynamically

    HI,can i ask some help,I am loading my table row dynamically

    Code:
     for (var  i = 0; i <5; i++) {
                   $('#lmytble tr:last').after('<tr><td>i</td><td>data1</td><td>data2</td></tr>');
                }
    how can i print the value of i?so that it will look something to this

    No. col1 col2
    1 data1 data2
    2 data1 data2
    3 data1 data2
    4 data1 data2
    5 data1 data2


    Thank you in advance.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,940
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Hi jemz,

    Do you mean string interpolation?

    Code:
    for (var  i = 0; i <5; i++) {
      $('#lmytble tr:last').after('<tr><td>' + i + '</td><td>' + data1 + '</td><td>' + data2 + '</td></tr>');
    }
    or did I misunderstand?

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi jemz,

    Do you mean string interpolation?

    Code:
    for (var  i = 0; i <5; i++) {
      $('#lmytble tr:last').after('<tr><td>' + i + '</td><td>' + data1 + '</td><td>' + data2 + '</td></tr>');
    }
    or did I misunderstand?

    Hi Pullo,

    Thank you so much ..yeah this is what i want...

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,940
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    No problem


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
  •