You are viewing limited content. For full access, please sign in.

Question

Question

How do I copy data from one field into another?

asked on December 18, 2015

I tried setting the default value to the field I want, but it isn't copying the data over:

Any idea why this is or what I need to do to get this to work?

 

Thanks,

0 0

Replies

replied on December 18, 2015

Hi David,

Can you clarify your request? Are you referring to taking the value of a field from one form and then having it copied to another field on a different form? Or is this about two fields on the same form and you just want whatever value a user inputs or selects in one field to be copied to the second field? Also, are these fields both single line fields?

Regards

0 0
replied on October 1, 2018

Hi Alex, 

 

Similar scenario here, where a table is being populated and we would like a column of that table to be populated on a multi-line field within the same form. 

 

Please note, this is also a dynamic table that is auto-populated from a DB lookup. 

Is that possible? 

 

With thanks, 

Ziad

0 0
replied on December 18, 2015

Alex,

 

It is the second scenario you laid out. I just one the value a user inputs to be copied into a second field on the same form. I need the number to be copied from a single field into a table.

0 0
replied on December 18, 2015

If you are using Forms 10, you can use the new Calculations/Formulas feature for this. For example, here is a form with a single line field, a number field, and then a table that has one row and two columns where the first column will get the copied single line value and the second column will get the copied number value.

I can then give the copied single line field a formula like below

I'd then do something similar with the copied number field. Then when I start the business process and start filling out the form, whatever I enter into the single line field and number field will then get copied into the corresponding fields in the table.

If you are using Forms 9.2, then you can do something similar with custom JavaScript. You can watch for changes made to the input fields and then set the values into the corresponding fields in the table. See the picture below and note the CSS class names for the input fields and the IDs of the fields in the table.

2 0
replied on December 21, 2015 Show version history

Alex,

Thanks for the help. I got the copying of the field to work. However, could you help with one more thing? I have the "Single Line" auto-populating a number based on another field. I need the sign of that number to be made negative. Then I need it to copy into the "Field84(1)" within the table. Then I need the calculation to take place of Points Prior + Adjustment = Points After. Right now it looks like the calculation is taking place, then the number is being copied into the Adjustment field ["Field84(1)"], and then the sign of the Single Line is being made negative. How do I go about reversing the order of everything? My code is currently as follows:

$(document).ready(function () {
    $(document).ready(function () {
		$(document).on('change', '.numberinput input', function() {
			$(this).val(-this.value);
		});
	$('.numberinput input').on('change', function() {
	$('[name="Field84(1)"]').val($('.numberinput input').val());
	});
    }).on('change','.cf-table-block input', sumtotal);
    function sumtotal() {
        var sum = 0;
        $('td.sum6').each(function () {
            var s = 0;
            $(this).find('input').each(function () {
                s += parseNumber($(this).val());
            });
            $(this).find('.subtotal input').val(s);
            sum += s;
        });
        $('.total6 input').val(sum);
      	if ($('.subtotal').length > 0) rowtotal();
    }
    function rowtotal() {
        var sum = 0;
        $('.cf-table-block tbody tr').each(function () {
            var s = 0;
            $(this).find('.sum6 input').each(function () {
                s += parseNumber($(this).val());
            })
            $(this).find('.subtotal input').val(s);
            sum += s;
        });
    }
    function parseNumber(n) {
        var f = parseFloat(n); //Convert to float number.
        return isNaN(f) ? 0 : f; //treat invalid input as 0;
    }
});

You can see how it's adding 3 + 0 = 3. Then inputting the 1 from single line. And then changing the sign within the Single Line field.

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.