Skip to main content
Inspiring
September 15, 2023
Question

Populate text field from button group AND another text field

  • September 15, 2023
  • 1 reply
  • 2314 views

Yet another road block for me!  I need to have my form auto populate a text field.  The issue I am having is that it needs to be populated from a variety of buttons, check boxes and other text fields.  I know how to do that if it just buttons and check boxes, but not how to add in the text fields.  I'm also hoping to add in some permanent words if something is typed into the text fields.  For example:

1. "Shortage" is chosen from the Group1 buttons

2. 9/2023 is inserted in the "Bill period" text field

3. $100.00 is inserted in the "Short amt" text field

4. "Late payment fee" is chosen from the Group2 buttons

I want the result text to say (not the colors, but colors are the tie-ins): "Shortage for 9/2023 bill period in the amount of $100.00 due to late payment fees."

 

Below is my form:

 

Below is my current script for the completed text box:

event.value = "";

var v1 = this.getField("Group1").valueAsString;

if(v1 == "Choice1"){

event.value += "BILL PERIOD balanced to zero, no O/S. ";

}

if(v1 == "Choice2"){

event.value += "Zero hours reported for BILL PERIOD. ";

}

if(v1 == "Choice3"){

event.value += "Shortage for ";

}

if(v1 == "Choice4"){

event.value += "Overage for ";

}

 

Beyond this, I am a little stumped as to how to include the text fields.  I also don't want the person completing the form to have to type "bill period in the amount of" after the date.  I just want them to enter the date and the rest will be inserted automatically because a date has been entered in the field.  Thanks all for your help!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
September 15, 2023

event.value += "Shortage for " + this.getField("Bill period").value + " bill period in the amount of $" + this.getField("Short amt").value + " due to late payment fees.";

Inspiring
September 15, 2023

Getting closer, but I don't want the words to show up in the text box UNLESS something is typed in the "Bill period" and "Short amt" fields.  The below is also problematic as it no longer shows the result of Group1, the "Bill period", the "Short amt", but does show the reason chosen from Group2:

event.value = "";
var v1 = this.getField("Group1").valueAsString;
if(v1 == "Choice1"){
event.value += "BILL PERIOD balanced to zero, no O/S. ";
}
if(v1 == "Choice2"){
event.value += "Zero hours reported for BILL PERIOD. ";
}
if(v1 == "Choice3"){
event.value += "Shortage for ";
}
if(v1 == "Choice4"){
event.value += "Overage for ";
}
event.value += this.getField("Bill period").value + " bill period in the amount of $" + this.getField("Short amt").value;
event.value = "";
var v2 = this.getField("Group2").valueAsString;
if(v2 == "Choice1"){
event.value += "due to employer miscalculation. ";}
if(v2 == "Choice2"){
event.value += "due to individual employee rate change. ";}
if(v2 == "Choice3"){
event.value += "due to late payment fees. ";}

try67
Community Expert
Community Expert
September 15, 2023

You need to include it in the condition where v1 == "Choice3"...

So if these fields are empty, and Choice3 is selected, you want the calculated field to be empty?