I am generating IDs of three sets of input boxes dynamically (autoincrement). So one set has IDs such as "inputbox1, inputbox2 etc" and the other set has IDs such as "value1, value2 etc" and the third set has "result1, result2 etc"
My basic function in jquery is this:
$("#button").click(function() {
var inputbox1 = parseInt($('#inputbox1').val());
var value1 = parseInt($('#value1').val());
$("#result1").val(inputbox1 + value1);
});
I don't know how many inputboxes will be there since they are dynamically generated. So how can i apply this same basic function for all the textboxes? I know that multiple functions like this would be inefficient and it is probably not the right way to go about it.
$("#button").click(function() {
var inputbox1 = parseInt($('#inputbox1').val());
var value1 = parseInt($('#value1').val());
$("#result1").val(inputbox1 + value1);
var inputbox2 = parseInt($('#inputbox2').val());
var value2 = parseInt($('#value2').val());
$("#result2").val(inputbox2 + value2);
});