Skip to content

Instantly share code, notes, and snippets.

@dhoss
Created April 28, 2010 21:05
Show Gist options
  • Save dhoss/382713 to your computer and use it in GitHub Desktop.
Save dhoss/382713 to your computer and use it in GitHub Desktop.
$("#add-row").click(function(){
var size = $(".workout-rows").length;
//size += 1;
var row ='<tr class="workout-rows">' +
'<td><input type="text" name="workout[exercise][' + size + '][name]" /></td>' +
'<td><input type="text" name="workout[exercise][' + size + '][repetitions]" size="3"/></td>'+
'<td><input type="text" name="workout[exercise][' + size + '][sets]" size="3"/></td>' +
'<td><input type="text" name="workout[exercise][' + size + '][weight]" size="4"/></td>' +
'</tr>';
$("#workout-table >tbody tr:last").after(row)
});
<table name="exercises" id="workout-table">
<tr>
<th>Name</th>
<th>Reps/Intervals</th>
<th>Sets</th>
<th>Weight/Distance/Time</th>
</tr>
[%- i=0 %]
[% WHILE i<=10 %]
<tr class="workout-rows">
<td><input type="text" name="workout[exercise][[% i %]][name]" /></td>
<td><input type="text" name="workout[exercise][[% i %]][repetitions]" size="3"/></td>
<td><input type="text" name="workout[exercise][[% i %]][sets]" size="3"/></td>
<td><input type="text" name="workout[exercise][[% i %]][weight]" size="4"/></td>
</tr>
[% i = i + 1 %]
[% END %]
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment