5 Replies Latest reply on Sep 5, 2017 7:44 AM by pnfyorch

    Help, adding Text to a text field using radio buttons!

    pnfyorch Level 1

      Hi guys and thank you for your answers!

       

      I have about 8 radio buttons in same group that intent to target only one Text field, so depending on user choice the Text field have a different text, how can I accomplish this using Javascript instead of creating 8 different Text fields/Default Values.

       

      radiob.jpg

      Thank you for your answers!

       

      I tried:

       

      var f = this.getField("Target");

      f.value = util.printd("This is a dummy text, This is a dummy text, This is a dummy text "());

       

      but obviously didn't work! 

        • 1. Re: Help, adding Text to a text field using radio buttons!
          try67 MVP & Adobe Community Professional

          As the custom calculation script of the text field enter something like this:

           

          var rdValue = this.getField("Radio1").valueAsString;
          if (rdValue=="Off") event.value = "";
          else if (rdValue=="Choice1") event.value = "Some text for option 1";
          else if (rdValue=="Choice2") event.value = "Some text for option 2";
          else if (rdValue=="Choice3") event.value = "Some text for option 3";
          // etc.
          

           

          Adjust the script to contain the correct field names, values and texts, of course.

          1 person found this helpful
          • 2. Re: Help, adding Text to a text field using radio buttons!
            pnfyorch Level 1

            Ohhh, Myyyyy  ohhh, myyyyy!!

             

            Totally correct!!

            Works beautiful!!!   Thank you so much!!!! 

             

            A

             

             

            • 3. Re: Help, adding Text to a text field using radio buttons!
              pnfyorch Level 1

              Wait a second... please...

               

              I wanted to use the target text field as samples so the user knows what to write, maybe just changing a few words and people names, but when you edit the text field and click away it goes back to the original text, doesn't save the new text! 

               

              How can this be accomplished???? please help!!! 

               

              I thought it was ready!! 

              • 4. Re: Help, adding Text to a text field using radio buttons!
                try67 MVP & Adobe Community Professional

                Ah, that requires a different approach. In that case you will need to use something like this as the Mouse Up event of each radio-button:

                 

                this.getField("Target").value = "Some text for option 1";  // script for the first button
                
                
                this.getField("Target").value = "Some text for option 2";  // script for the second button
                
                this.getField("Target").value = "Some text for option 3";  // script for the third button
                
                1 person found this helpful
                • 5. Re: Help, adding Text to a text field using radio buttons!
                  pnfyorch Level 1

                  It's working!

                  ------------------------------------------------------------------------------------------ -----------------------

                  One last question, while finishing this form:

                   

                  I have 18 Radio Buttons and only the first one have sub-menu (4 Buttons) that show only if that Rd1 is checked.

                  This is what I did:

                  Rd1: this.getField("Buttons").display = display.visible;
                  Rd2: this.getField("Buttons").display = display.hidden;
                  Rd3: this.getField("Buttons").display = display.hidden;
                  Rd4: this.getField("Buttons").display = display.hidden;
                  Rd5: this.getField("Buttons").display = display.hidden;
                  Etc....(to Rd18)
                  

                   

                  It's works, but I feel It should be a better way to do it.

                  So I tried these:

                   

                  if(event.target.value =="Yes"){
                  this.getField("Buttons").display = display.visible;
                  }
                  else {
                  this.getField("Buttons").display = display.hidden;
                  }
                  

                  But it's doesn't work!

                   

                  I also tried "On blur,  this.getField("Buttons").display = display.hidden;", but when I click on a button, all 4 go hidden,

                   

                  showhide.jpg

                   

                  So my question is: Is there a short code to be place only on RB1 and get the same result as I have it working now?

                   

                   

                  Thank you so much!!!

                  I appreciate your help!