Skip to main content
Inspiring
September 26, 2024
Answered

Using multiple checkboxes to populate text field with the checkbox values

  • September 26, 2024
  • 2 replies
  • 824 views

Hi there,

 

Is it possible to click checkboxes and get the value to appear in a text field?

 

Checkbox values are:

Level Life

Increasing Life

Decreasing Life

Level CI_CILC

 

The name of the Text Field is "TextField1".

 

If possible I would like to try and get the textfield populated, if all 4 checkboxes are active, as:

'Level Life | Increasing Life | Decreasing Life | Level CI_CILC '

 

Any help would be greatly appreciated

 

Steve

This topic has been closed for replies.
Correct answer try67

You can do it using this code, as the custom calculation script of the text field:

 

var values = [];
if (this.getField("Check Box 5").valueAsString!="Off") values.push("Level Life");
if (this.getField("Check Box 6").valueAsString!="Off") values.push("Increasing Life");
if (this.getField("Check Box 7").valueAsString!="Off") values.push("Decreasing Life");
if (this.getField("Check Box 8").valueAsString!="Off") values.push("Level CI_CILC");
event.value = values.join(" | ");

2 replies

Nesa Nurani
Community Expert
Community Expert
September 26, 2024

If you wish to show values when all 4 checkboxes are active, use this as custom calculation script of text field:

var checkedValues = [];
for (var i=5; i<=8; i++) {
 var f = this.getField("Check Box " + i).valueAsString;
  if (f !== "Off") {
   checkedValues.push(f);}}
if (checkedValues.length === 4) {
 event.value = checkedValues.join(" | ");} 
else {
 event.value = "";}
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 26, 2024

You can do it using this code, as the custom calculation script of the text field:

 

var values = [];
if (this.getField("Check Box 5").valueAsString!="Off") values.push("Level Life");
if (this.getField("Check Box 6").valueAsString!="Off") values.push("Increasing Life");
if (this.getField("Check Box 7").valueAsString!="Off") values.push("Decreasing Life");
if (this.getField("Check Box 8").valueAsString!="Off") values.push("Level CI_CILC");
event.value = values.join(" | ");
Inspiring
September 26, 2024

Brilliant. Many thanks,

 

Steve