jQuery to dynamically add table rows -
i want dynamically add table rows on change of select wrote script this, system not dynamic yet.
<script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#noofsegments").change(function(){ var counter=${#noofsegments}.val(); for(i=0; i<counter; i++){ var row = $("<tr><td>"i"</td><td>"i"</td><td>"i"</td><td>"i"</td><td>"i"</td></tr>"); $("#segmenttable").append(row); } }); }); </script> <select id="noofsegments"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select>
and #segmenttable table id above script gives me "uncaught syntaxerror: unexpected token { " error can please suggest me solution
you missing lot of parantheses, quotes , plus signs. should work:
$(document).ready(function(){ $("#noofsegments").change(function(){ var counter=$('#noofsegments').val(); for(i=0; i<counter; i++){ var row = $("<tr><td>" + + "</td><td>" + + "</td><td>" + + "</td><td>" + + "</td><td>" + + "</td></tr>"); $("#segmenttable").after(row.html()); } }); });
Comments
Post a Comment