Copy link to clipboard
Copied
Hello,
I am trying to set up a form that will display the word "standard" in a field next to a paired checkbox if checked but otherwise keep the value of what the user types.
Right now, I have this in the custom calculation script for the text field called upper1:
var upper1= this.getField("upper1");
if (this.getField("Check1").value != "Off")
upper1.value = "Standard"
else
upper1.display = display.visible
Is there a different way that doesn't require overriding the value of upper1? I'd like to not overwrite the user-inputted value if possible and just have it selectively display the user value or not. User value could be blank if they don't want it.
Alternatively, I'd like to set it to display the export value of the checkbox when checked and the user-inputted value if unchecked.
So lets be clear about what you are trying to do. On your form there is a text field next to a check box. User's can enter text into the text field. If the check box is checked, then the word "Standard" is appended or prefixed onto to text the user entered?
The problem with this process. is that if the value of the field is modified you need to be able to parse the text field to remove the word standard. This is (slightly) problematic. It's much easier to have two fields as Bernd suggests. Or t
...Copy link to clipboard
Copied
Use 2 fields. One with the value Standard. The other for the user input.
Copy link to clipboard
Copied
I don't have the space for that.
Alternatively being able to clear out "standard" if unchecking but not over-riding any then user inputted value when I move to another line would be helpful.
Copy link to clipboard
Copied
So lets be clear about what you are trying to do. On your form there is a text field next to a check box. User's can enter text into the text field. If the check box is checked, then the word "Standard" is appended or prefixed onto to text the user entered?
The problem with this process. is that if the value of the field is modified you need to be able to parse the text field to remove the word standard. This is (slightly) problematic. It's much easier to have two fields as Bernd suggests. Or to use the format event to add the appearance of the word "Standard', rather than changing the value of the text field.
To use the formatting solution, do this. Remove the calculation script. Add this code to a custom format script for the text field.
if (this.getField("Check1").value != "Off")
event.value = "Standard - " + event.value;