Hi,
The image below is my form:
How can I make the content of "SingleLine" and "SingleLine2" merge and appear in "Result" as soon as both fields contain something?
Regards,
Hi,
The image below is my form:
How can I make the content of "SingleLine" and "SingleLine2" merge and appear in "Result" as soon as both fields contain something?
Regards,
You can do this without using custom JavaScript by using the =CONCATENATE() function in the calculation in Result. This will combine even if one of the fields are empty, but you could resolve that by making both single line fields required.
Edit - you can combine multiple variables by separating them with commas. =CONCATENATE(Val1, Val2, Val3)
Here's sample JS
$(document).ready(function () { $('.hasvalue input').on('change', function () { if ($('#Field1').val() !== '' && $('#Field2').val() !== '') { $('.result input').val($('#Field1').val() + " - " + $('#Field2').val()); } else { $('.result input').val(''); } }); });
Give the two "single line" fields a CSS class like hasvalue. Then give the "result" field a CSS class like result. The above checks for changes in the fields with the hasvalue class and if both fields are not empty, then combine the values and set it into the result field. Otherwise, leave the result field blank.
Thank you Eric and Alex. I have tried the non-javascript method and it worked perfectly