Reputation: 1083
I have two input number fields that show total with some jQuery.
Calculate total:
$('form#lines-form-1 :input[type="number"]').change(function() {
var tot = 0;
$('form#lines-form-1 :input[type="number"]').each(function() {
tot += +this.value;
});
$('#tot-qty').text(tot);
});
JSFiddle: https://jsfiddle.net/q3z4w98o/2/
After entering some numbers on form A press Total to show results.
When clicked Copy how to transfer the total value to Form B's first input field?
E.g.
Upvotes: 0
Views: 814
Reputation: 8078
Use the following code JS Fiddle:
$("button.copy-btn").click(function() {
$('input[name="i3"]').val($("#tot-qty").text());
})
This bit copies the text value inside the #tot-qty
span and sets the i3
input value to that when clicking the "Copy" button.
Upvotes: 2