Zo Has
Zo Has

Reputation: 13038

Add rows(<tr>) to table(<table>)?

I want to add rows to a table dynamically inside a for loop. User selects 1,2,3 or 4 from a radio button list and the corresponding number of rows get added to the table. The table would initially have no rows at all.

Edit:

I want to add rows equal to selected item's value with a loop probably (maybe there is some other way) and add months to the current date with a serial no.

Here is my Fiddle JSFiddle

I need to put the dates inside labels so I later fetch them server side through javascript or some other method.

Upvotes: 0

Views: 2485

Answers (1)

justin.lovell
justin.lovell

Reputation: 675

Sure.

var num = parseInt($('.radio-button-list:selected').val());
for (var i = 0; i < num; i++) {
    var row = $('<tr></tr>');

    // todo: build your table row appropriately here
    $('#my-table').append(row);
}

Upvotes: 6

Related Questions