Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How do you populate 1 text box with multiple dropdown values

Avatar

Level 4

I can populate a text box with a value from a dropdown, however if I have 2 dropdown values going to the same text box (multi-line), the second dropdown value removes the first value.

(Similar code on Dropdown 1 and Dropdown 2)

Change Event - JavaScript

if(xfa.event.newText == 'No'){

form1.page1.subform2.description.rawValue="No location listed";

}

if(xfa.event.newText == "Partial location"){

form1.page1.subform2.description.rawValue="Partial location listed";

}

Do I have to Concat the fields in the 1 text field to get it to list multiple dropdown values, and if so how do I do that?

Thanks in advance for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Solved:

Place this script in the subform root level in the FormReady event -JavaScript.

var oList = this.getDeltas ();

for (i=0; i < oList.length; i ++)

{

   var oDelta = oList.item(i);

   oDelta.restore ();

}

Answer was found at http://forms.stefcameron.com/2008/09/29/restoring-the-of-your-form/

View solution in original post

11 Replies

Avatar

Level 10

Is this what you are after?

// form1.page1.subform1.tf::calculate - (JavaScript, client)

if (form1.page1.subform1.color.selectedIndex != -1 && form1.page1.subform1.fruit.selectedIndex != -1) {

          this.rawValue = form1.page1.subform1.color.rawValue + "\n" + form1.page1.subform1.fruit.rawValue;

}

else {

          if (form1.page1.subform1.color.selectedIndex != -1 && form1.page1.subform1.fruit.selectedIndex == -1) {

    this.rawValue = form1.page1.subform1.color.rawValue;

          }

          else {

    if (form1.page1.subform1.color.selectedIndex == -1 && form1.page1.subform1.fruit.selectedIndex != -1) {

      this.rawValue = form1.page1.subform1.fruit.rawValue;

    }

          }

}

Steve

Avatar

Level 4

Thanks Steve for your help on this, you are amazing!

That is close.  I am actually trying to display specific values from the dropdown. 

So for your example, lets say I want just Red and Green values from the color field and Apples and Pears from the Fruit field to populate the textbox.  I also want to change the drop down value of "Red" to say "Ruby Red" to in the Text box.  Is that possible?

Avatar

Level 4

YAY - I got it figured out!

On Color Drop Down - Change Event, JavaScript

if (xfa.event.newText == 'Red') {

     form1.page1.subform1.textbox.rawValue="Ruby Red";

}

if (xfa.event.newText == 'Green'){

     form1.page1.subform1.textbox.rawValue="Light Green";

}

On Fruit Drop Down - Change Event, JavaScript

if (xfa.event.newText == 'Apple') {

     form1.page1.subform1.textbox.rawValue="Granny Smith";

}

if (xfa.event.newText == 'Pear'){

     form1.page1.subform1.textbox.rawValue="Bartlett";

}

On Text Box - Calculate Event, JavaScript

this.rawValue = form1.page1.subform1.color.rawValue + "\n" + form1.page1.subform1.fruit.rawValue; 

Thank you Steve for pointing me into the right direction.

Avatar

Level 4

It works for only a few drop down values, if I get more than 6 going it displays only the last drop-down value.  What am I doing wrong?

Avatar

Level 4

Changed the event from Change to Calculated and then the value type "Calculated - Read only" to "Calculated - User can override" and it didn't work.  Text box is blank.

Avatar

Level 4

HUMMMMM – How would I add the dropdown fields to the text box?

Eve Tracy

Avatar

Level 10

You need to remove the script from each drop-down change event and put all the script on the description calculate event. For example,

// form1.NonCompliancePage.subform2.description::calculate - (JavaScript, client)

var str = "";

if (form1.recordKeepingPage.RecordKeeping.rk_BusName.rawValue == "Required Records - No business name listed" || form1.recordKeepingPage.RecordKeeping.rk_BusName.rawValue == "Required Records - Partial business name listed") {

          if (form1.recordKeepingPage.RecordKeeping.rk_BusName.rawValue == "Required Records - No business name listed") {

                    str = "Required Records-No business name listed" + "\n";

          }

          else {

                    str = "Required Records - Partial business name listed" + "\n";

          }

}

if (form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "No" || form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "Partial address" || form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "P.O Box only") {

          if (form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "No") {

                    str =  str + "Required Records-No address of the application listed" + "\n";

          }

          else {

                    if (form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "Partial address") {

                              str = str + "Required Records-Partial address listed" + "\n";

                    }

                    else {

                              str = str + "Required Records-PO Box only listed" + "\n";

                    }

          }

}

this.rawValue = str;

Steve

Avatar

Level 4

Thank you so much!  This is exactly what I was wanting to do, you are Amazing!

Avatar

Level 4

I have another question regarding the script to populate a text box with multiple dropdown values. 

How do you save the form state (keep the page visible after it has been saved)?  This form will be connected to a signature pad, so it has to be certified and preserve scripting changes to form when saved is set to manually.  

I can save the form state of several other hidden pages using this code in the initialize event:

 

if

(this.rawValue==1)

{subformName.presence="visible";}

else

{subformName.presence="hidden";}

However, since I have multiple fields writing to a text box using the calculated event, I can't seem to save the form state using the code above. 

Please help, I have been searching forums and can not find a solution to this one.

Avatar

Correct answer by
Level 4

Solved:

Place this script in the subform root level in the FormReady event -JavaScript.

var oList = this.getDeltas ();

for (i=0; i < oList.length; i ++)

{

   var oDelta = oList.item(i);

   oDelta.restore ();

}

Answer was found at http://forms.stefcameron.com/2008/09/29/restoring-the-of-your-form/