1. Generate .....
2. Calculation...
Total 6 textbox and chk box generated and fill the value in all textbox but checkbox check only 3 textbox then sum button click calculate only checked textbox value and display in total ...
please help me ....
my textbox generated code and Calculate value using without Checkbox ..
<script>
$(document).ready(function ()
{
$("#btnshow").click(function ()
{
var rows = $("#txtRows").val();
var columns = $("#txtColumns").val();
var htmlData = "";
for (var i = 0; i < rows; i++)
{
//var $ctr = $('<input/>').attr({ type: 'checkbox', name: 'chk' }).addClass("chk");
//$("#tblGnrate").append($ctrl);
htmlData += "<tr>";
for (var j = 0; j < columns; j++)
{
htmlData += "<td><input type='text' name='txtValue' id='txtBox" + i + "" + j + "' /></td>"
}
htmlData += "</tr>";
}
$("#tblGnrate").html(htmlData);
});
// sum all the text box values
var Total = 0;
$("#btnsum").click(function ()
{
$('#tblGnrate').each(function (i, row)
{
var $row = $(row), $txtbox = $row.find('input[name="txtValue"]');
$txtbox.each(function (i, txtbox)
{
var $t = $(txtbox);
Total = Total + parseInt($t.val(),10);
});
});
alert(Total);
Total = 0;
});
});
</script>
</head>
<body>
Rows:<input type="text" id="txtRows" />
Columns:<input type="text" id="txtColumns" /><br /><br /><br />
<input type="button" id="btnshow" value="Generate" />
<input type="button" id="btnsum" value="Calculate" />
<table id="tblGnrate"></table>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------