Sunday, 29 September 2013

jQuery dynamic generated table rows with input fileds need sum and validation

jQuery dynamic generated table rows with input fileds need sum and validation

I need help in jQuery generated dynamic table rows with input fields and
select box, I want when I select in select box one input field two is
disabled and when I select two input field two is disabled as I added more
rows different values of input fields, I also need sum of all inserted
rows input fields my code is here :
<table id="mytable">
<thead>
<th>Course</th>
<th>Fee for Coures 1</th>
<th>Fee for final course</th>
</thead>
<tbody>
<tr>
<td>
<select name="code">
<option value="1">javascript</option>
<option value="2">PHP mysql</option>
</select>
</td>
<td><input type="text" id="fee" name="js-fee"></td>
<td><input type="text" id="fee" name="php-fee"></td>
</tr>
</tbody> </table>
my jQuery code is here it is working true, just need help for sum of all
inserted rows input and disabled field if select one field two is disable
and if selected two field one is disable all row can have different values
<script type="text/javascript">
$(document).ready(function () {
$("#insert-more").click(function() {
$("#mytable").each(function () {
var tds = '<tr>';
jQuery.each($('tr:last td', this), function () {
tds += '<td>' + $(this).html() + '</td>';
});
tds += '</tr>';
if ($('tbody', this).length > 0) {
$('tbody', this).append(tds);
} else {
$(this).append(tds);
}
});
});
});
</script>

No comments:

Post a Comment