Copy link to clipboard
Copied
I have text field and 3 checkboxes c1,c2 and c3
text field is multiline, I want to have static text and then if checkbox is checked to add line of text
or remove if checkbox is unchecked. Is that possible?
Put this code in text field as 'custom calculation script':
var text = "Static text goes here";
if(this.getField("c1").valueAsString != "Off")
text += "\nText for c1 goes here";
if(this.getField("c2").valueAsString!= "Off")
text += "\nText for c2 goes here";
if(this.getField("c3").valueAsString!= "Off")
text += "\nText for c3 goes here";
event.value = text;
Sure you can use like this:
var text = "Static text goes here";
if(this.getField("g1").valueAsString == "Choice1")
text += "\nText for choice1 goes here";
if(this.getField("g1").valueAsString == "Choice2")
text += "\nText for choice2 goes here";
if(this.getField("g1").valueAsString == "Choice3")
text += "\nText for choice3 goes here";
event.value = text;
Copy link to clipboard
Copied
Put this code in text field as 'custom calculation script':
var text = "Static text goes here";
if(this.getField("c1").valueAsString != "Off")
text += "\nText for c1 goes here";
if(this.getField("c2").valueAsString!= "Off")
text += "\nText for c2 goes here";
if(this.getField("c3").valueAsString!= "Off")
text += "\nText for c3 goes here";
event.value = text;
Copy link to clipboard
Copied
Thank you so much.
Copy link to clipboard
Copied
Hi, I decided I wanna try another aproach and use 3 radio buttons named g1 with Choice1,2,3
Can i adapt your code to do that?
Copy link to clipboard
Copied
Sure you can use like this:
var text = "Static text goes here";
if(this.getField("g1").valueAsString == "Choice1")
text += "\nText for choice1 goes here";
if(this.getField("g1").valueAsString == "Choice2")
text += "\nText for choice2 goes here";
if(this.getField("g1").valueAsString == "Choice3")
text += "\nText for choice3 goes here";
event.value = text;
Copy link to clipboard
Copied
Is there a way of doing this checkbox merging into a textfield using the Checkboxes Export Value rather than writing the "Text for c1 goes here" in the code?
Copy link to clipboard
Copied
Yes, you can use it like this:
var text = "Static text goes here";
if(this.getField("c1").valueAsString != "Off")
text += "\n"+this.getField("c1").valueAsString;
if(this.getField("c2").valueAsString!= "Off")
text += "\n"+this.getField("c2").valueAsString;
if(this.getField("c3").valueAsString!= "Off")
text += "\n"+this.getField("c3").valueAsString;
event.value = text;
Copy link to clipboard
Copied
Love ya work Nesa!
Copy link to clipboard
Copied
Is it possible to adapt this script so that rather than code in individual checkbox values (c1,c2,c3) I could group them and then use group1 for group1.c1, group1.c2, group1.c3 checkboxes? If not, is there an alternative way of doing so?
Copy link to clipboard
Copied
You could store values of c1,c2,c3 in variable and then call it when needed.
Copy link to clipboard
Copied
Sorry Nesa, I'm new at writing JS. Could you please show me how to do this?