4 Replies Latest reply on Feb 3, 2010 12:11 PM by gkaiseril

    Need help getting this code to work

    MelMuff

      I am trying to get this code to work using "if else statment" but it will only do the first part and not do the second part in the else statement. Can anyone help me out? Here is the code:

       

      var R1 = this.getField("Registration Fees1");
      var R2 = this.getField("Registration Fees2");
      var R3 = this.getField("Registration Fees3");
      var R4 = this.getField("Registration Fees4");

       

      var R0 = 0

       

      if (R0 == 0)
        {
        event.value = Math.floor(R1.value);
        }
      else
        {
        event.value = Math.floor(R2.value + R3.value + R4.value);
        }

       

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

       

      I did notice that if I fiddled around this this part:

       

      if (R0 == 0)

       

      sometimes I can get the second part to work but not the first. I need it to do either or and this is getting frustrating.

       

       

      I might also not even need "var R0 = 0". I put that there for the condition part. If that is what is causing the problem, I can take it out. But then what would the condition be? For this form, the default is 0 and then the calculation follows by user clicking on different prices. The first part is if they want to pay for the full conference and the second part is if they want to pay for either Monday, Tuesday or Wednesday or 2 of the 3 days. Is it possible to get this to work with both parts together? I am still stuck on getting just one or the other working. Any help would be greatly appreciated. Thanks in advance.

        • 1. Re: Need help getting this code to work
          MelMuff Level 1

          I have posted this on another message board and a user, named gkaiseril, offered me this solution but it hasn't worked either.

           

          // all four days
          var R1 = this.getField("Registration Fees1").value;
          // Monday
          var R2 = this.getField("Registration Fees2").value;
          // Tuesday
          var R3 = this.getField("Registration Fees3").value;
          // Wednesday
          var R4 = this.getField("Registration Fees4").value;
          var Fee = 0
          event.value = ''; // default value
          if (R1 != 'Off') {
            Fee = Number(R1) + Fee;
          } else {
            if(R2 != 'Off') {
               Fee = Number(Fee) + R2;
               }
            if(R3 != 'Off') {
               Fee += Number(R3);
               }
            if(R4 != 'Off') {
               Fee = Number(R4) + Fee;
               }
            }
          event.value = Fee;
          • 2. Re: Need help getting this code to work
            gkaiseril MVP & Adobe Community Professional

            Here is a working sample.

             

            You need to fill in the export values for the check boxes.

            1 person found this helpful
            • 3. Re: Need help getting this code to work
              MelMuff Level 1

              This is what I was looking for. It's still not working for me but it has given me a new idea. I noticed that you used check boxes while I was completely using radio buttons. Maybe that was my problem. I am going to try experimenting with check boxes. Thanks.

              • 4. Re: Need help getting this code to work
                gkaiseril MVP & Adobe Community Professional

                There is a subtle difference between a Radio Button and a Check Box. Radio Buttons can not be unselected once it is selected while a check box can be unselected by clicking on the selected check box.

                 

                Both Radio Buttons and Check Boxes when given the same field name and different export values will create an exclusionary group or only allow one of the buttons to be selected.