$(document).ready(function(){
var i = 1; var cnt = 0; var html = '';
//create object
for(i=1;i<=cnt;i++){
html = '<p>Number : '+i+' ';
html += '<input type ="text" name="value[]" id="value_'+i+'" />';
html += ' * <input type ="text" name="count[]" id="count_'+i+'" />';
html += ' = <input type ="text" name="result[]" disabled id="result_'+i+'" />';
html += '</p>';
$("form").append(html);
}
$('input[id^="value"], input[id^="count"]').keyup(function(){
//find value1
var value1 = parseFloat($(this).val());
//check if is not a number, skip
if(isNaN(value1)) return false;
//find type of trigged
var type = $(this).attr("id").split("_");
//find number
var no = parseInt(type[1]);
//delete number
type = type[0];
//find Multiplier
var value2 = parseFloat($('#'+(type=="value"?"count":"value")+"_"+no).val());
//check if is not a number, skip
if(isNaN(value2)) return false;
//chenge value
$("#result_"+no).val(value1*value2);
//set start value
var all_result = 0;
//travel all result
$('input[id^="result"]').each(function(){
var curr_val = parseFloat($(this).val());
if(!isNaN(curr_val)) all_result += curr_val;
});
//update all value
$("#all_result").html(all_result);
});
});