Copy link to clipboard
Copied
Hi, can anyone help me with the Q in this scenario please?
I want to link three different text fields together, Field 1 (Mechanical), Field 2 (Electrical) and Field 3 (job description). Users for the form are supposed to choose between Field 1 and Field 2 to put in the job description, and that will populate into Field 3, so how can I achieve it? Because I have to name Field 1 and 2 differently to make them appear or disappear with radio buttons.
Thanks very much
Regards,
Use this as custom calculation script of Field 3 (job description):
var f1 = this.getField("Mechanical").valueAsString;
var f2 = this.getField("Electrical").valueAsString;
if(f1)
event.value = f1;
else if(f2)
event.value = f2;
else
event.value = "";
Yes, you do, but if you name them consistently ("Mechanical1", "Electric1", "Job Description1", "Mechanical2", "Electric2", "Job Description2", etc.) then it can be automated using a script. The code itself can be placed as a doc-level function and then just called from each field.
By the way, I would also add a script to each of the first fields to clear the value of the other one, if you want to make sure they are not both filled at the same time. Something like this can be used as the custo
...Copy link to clipboard
Copied
Use this as custom calculation script of Field 3 (job description):
var f1 = this.getField("Mechanical").valueAsString;
var f2 = this.getField("Electrical").valueAsString;
if(f1)
event.value = f1;
else if(f2)
event.value = f2;
else
event.value = "";
Copy link to clipboard
Copied
Thanks Nesa, it works, is there a way to implement it if I have nearly a hundred "Field 3"s, or do I have to put the script to each F3 individually? Appreciate your help.
Regards,
Copy link to clipboard
Copied
Yes, you do, but if you name them consistently ("Mechanical1", "Electric1", "Job Description1", "Mechanical2", "Electric2", "Job Description2", etc.) then it can be automated using a script. The code itself can be placed as a doc-level function and then just called from each field.
By the way, I would also add a script to each of the first fields to clear the value of the other one, if you want to make sure they are not both filled at the same time. Something like this can be used as the custom Validation script of "Mechanical1", for example:
if (event.value) this.getField("Electric1").value = "";