4 Replies Latest reply on Mar 7, 2017 2:43 AM by try67

    How can I make check boxes generate paragraphs of text

    soulglowdeej Level 1

      Hi,

       

      How can i make check boxes generate text?

       

      I have 9 check boxes, each with their own individual Export Value. (The Export Value is a paragraph of text.)

       

      I would like it so when people choose the check boxes they need, the result is shown in a text field, so I'm trying to write a custom calculation script.

      My Checkboxes are called "Check Box 1" "Check Box 2" etc, and the results box is called "Strength results".

       

      I can get it so I get all the text in one line, and the the word "Off" for each checkbox that isn't checked however I'm wanting:

      Check Box 1 text (or which ever is selected)

      Line break \n

      Check Box 2 text (or which ever is selected)

      Line break \n

      Check Box 3 text (or which ever is selected)

       

      Can you help?

       

      Thanks

        • 1. Re: How can I make check boxes generate paragraphs of text
          Joel_Geraci Adobe Community Professional

          Rename your checkboxes to "CheckBox.1", CheckBox.2" etc. then use the following code as your calculation in the field where you want the paragraphs to appear. "\n\n" will put an additional line break between the paragraphs.

           

          var paras = [];

          var fields = this.getField( "CheckBox" ).getArray();

          // sort by name

          fields.sort( function( a, b ) {

               var nameA = a.name.toUpperCase(); // ignore upper and lowercase

               var nameB = b.name.toUpperCase(); // ignore upper and lowercase

               if ( nameA < nameB ) {

                    return -1;

               }

               if ( nameA > nameB ) {

                    return 1;

               }

           

           

               // names must be equal

               return 0;

          } );

           

           

          for ( var i = 0; i < fields.length; i++ ) {

               var field = fields[ i ];

               if ( field.isBoxChecked( 0 ) ) {

                    paras.push( field.value )

               }

          }

          event.value = paras.join( "\n\n " )

          1 person found this helpful
          • 2. Re: How can I make check boxes generate paragraphs of text
            soulglowdeej Level 1

            Amazing!! this is perfect.

             

            Thank you so much Joel

            • 3. Re: How can I make check boxes generate paragraphs of text
              soulglowdeej Level 1

              Another question if anyone knows the answer (not as pressing as the other, hence not creating another thread).

               

              We can set the Export Value of check box to be text easily within the properties menu, however, how can you insert a line break in a body of text in the export value? So you can export multiple paragraphs, as opposed to one...Any ideas?

               

              Thanks

              • 4. Re: How can I make check boxes generate paragraphs of text
                try67 MVP & Adobe Community Professional

                You can only do that using a script, but it's not recommended. If you really want to do it I would recommend replacing the line-breaks with some kind of place-holder character, like the pipe symbol ("|"), and then you'll just need to replace it back when applying the value to your multiline text field.

                1 person found this helpful