3 Replies Latest reply on Apr 20, 2011 12:01 AM by George_Johnson

    Check Box

    Swiss_Cheeze

      Hello,  New to coding or at least been a long time.  Trying to make a form for a friend.

       

      Is there a way to make a value present if a checkbox is checked.

       

      []  $30 and make that value $30 appear in another box.  Or if you uncheck it the value disappears?

       

      Kinda in a hurry for an appointment and if you need more clarification I will.

       

      Thank you

        • 1. Re: Check Box
          George_Johnson MVP & Adobe Community Professional

          In the Mouse Up event of the check box, do something like:

           

          (function () {
          
              // Get a reference to the text field
              var f = getField("text1").value;
          
              // Get the value of this check box. Will be 30 if selected
              var v = event.target.value;
          
              // Set the value of the text field
              if (v !== "Off") {
                  f.value = v;
              } else {
                  f.value = "";
              }
          
          })();
          

           

          This assumes that you set the export value of the check box to the number 30.

           

          The other approach is to set up the text field to be a calculated field and use the following custom Calculate script:

           

          (function () {
          
              // get the value of the check box
              var v = getField("check1").value;
          
              // Set this field's value
              if (v !== "Off") {
                  event.value = v;
              } else {
                  event.value = "";
              }
          
          })();
          

           

          Replace "text1" or "check1" with the actual names of the field you're using.

          • 2. Re: Check Box
            Swiss_Cheeze Level 1

            George,

             

            I believe these is probably the answer but since I am a newb I can not figure out what exactly to do.

             

            In my checkbox say "Check box 2" I put, mouse up, run a javascript,and what you put on top with "acid wash cost" in place of "text1" and

            f.value = 30.00;

             

            In my cost box I put the second with "check1" replaced with "Check box 2" and event.value = 0; Value in the acid wash cost = 0.

             

            I have tried different things but it hasn't been working for me.

             

            "The value entered does not match the format of the field [Acid Wash Cost].

             

            It's been a long time.  I was hoping that I would get answers to help instead of picking up a book, but I might need to do that too.

            • 3. Re: Check Box
              George_Johnson MVP & Adobe Community Professional

              You can use one or the other, but don't use both. I was just showing two different approaches you can take. I would probably remove the calculate script from the text field.

               

              The error will probably go away when you do, but if it doesn't, what have you set up as the format type for the text field?