Thursday, 5 September 2013

Limit number of rows added to 10 in 'Add Row' function

Limit number of rows added to 10 in 'Add Row' function

I have an "Add Row" function in java script. How do I limit the number of
rows added to no more then 10 rows? Here is my code. Thanks for the help!
$(document).on('click','#addAddOnDay',function(){
var rowCount = $('#addOnDay tr').length + 1;
var rowClass = (rowCount % 2 != 0) ? 'rowOdd' :
'rowEven';
$('#addOnDay').append('<tr class="'+ rowClass +'"> \
<td
align="center"><input
type="text"
class="text"
style="width:
99%;"
/></td>
\
<td
align="center"><input
type="radio"
name="4a_1">
<label>Yes</label>
&nbsp;
<input
type="radio"
name="4a_1"
checked>
<label>No</label></td>
\
<td
align="center">20000
or
95%</td>
\
<td
align="center"
class="rollUpDisplay">1</td>
\
</tr>');
});

No comments:

Post a Comment