1 Reply Latest reply on Oct 27, 2015 9:15 AM by kodiem13114922

    Dropdown Menu Calculations

    kodiem13114922

      Hello everyone,

       

      I am creating a form for my work and have run into a stumbling block. I am hoping someone can help me. What I have is a Drop Down menu with  4 options to chose from (well actually 5 but the 5th is to make the fields go blank). Depending on the option chosen a Text Field(s) are populated. the name of these fields "pkgdis 1-7" also help change the value of another set of Text field(s) labeled "PKGPrice 1-7"

      I also have two more Drop down menus that prepopulate additional text fields ( "opprice" and "opprice1.0")

      The issue I have is field "PKGprice2", "PKGPrice3", "PKGPrice4" and "PKGPrice7" are my Total value fields for this dropdown menu. So I am unable to preform a simple calculation of feild1 + field 2 = field 5.

       

      What I would like to do is to have a text field "Addons" calculate the total of something like this

       

      PKGprice2 + opprice + opprice1.0= "Addons"

      PKGprice3 + opprice + opprice1.0= "Addons"

      PKGprice4 + opprice + opprice1.0= "Addons"

      PKGprice7 + opprice + opprice1.0= "Addons"

       

      I have very little experience with JavaScript so if anyone can help me out that would be great. I've copied the JS from my dropdown menu so you can see how I am prepopulating the text fields.

       

      var sNewSel = event.value;
           switch (sNewSel) {
             case "Standard Protection Package #1":
               this.getField("pkgdis").value = "Door Edge Guard(s) Protection";
         this.getField("pkgdis1").value = "Door Cups Protection";
         this.getField("pkgdis2").value = "Total Protection Package Value";
         this.getField("PKGPrice").value = "$50.00";
         this.getField("PKGPrice1").value = "$100.00";
         this.getField("PKGPrice2").value = "$150.00";
         this.getField("pkgdis3").value = " ";
         this.getField("pkgdis4").value = " ";
         this.getField("pkgdis5").value = " ";
         this.getField("pkgdis6").value = " ";
         this.getField("pkgdis7").value = " ";
         this.getField("PKGPrice3").value = " ";
         this.getField("PKGPrice4").value = " ";
         this.getField("PKGPrice5").value = " ";
         this.getField("PKGPrice6").value = " ";
         this.getField("PKGPrice7").value = " ";

               break;

       

           case "Standard Protection Package #2":
               this.getField("pkgdis").value = "Door Edge Guard(s) Protection";
         this.getField("pkgdis1").value = "Door Cups Protection";
         this.getField("pkgdis2").value = "Mirror Protection";
         this.getField("PKGPrice").value = "$50.00";
         this.getField("PKGPrice1").value = "$100.00";
         this.getField("PKGPrice2").value = "$45.00";
         this.getField("PKGPrice3").value = "$195.00";
         this.getField("pkgdis3").value = "Total Protection Package Value";
         this.getField("pkgdis4").value = " ";
         this.getField("pkgdis5").value = " ";
         this.getField("pkgdis6").value = " ";
         this.getField("PKGPrice4").value = " ";
         this.getField("PKGPrice5").value = " ";
         this.getField("PKGPrice6").value = " ";
         this.getField("PKGPrice7").value = " ";
        
               break;

       

           case "Premium Protection Package":
             this.getField("pkgdis").value = "Door Edge Guard(s) Protection";
         this.getField("pkgdis1").value = "Door Cups Protection";
         this.getField("pkgdis2").value = "Mirror Protection";
         this.getField("pkgdis3").value = "Hood Protection";
         this.getField("pkgdis4").value = "Total Protection Package Value";
         this.getField("pkgdis5").value = " ";
         this.getField("pkgdis6").value = " ";
         this.getField("PKGPrice").value = "$50.00";
         this.getField("PKGPrice1").value = "$100.00";
         this.getField("PKGPrice2").value = "$45.00";
         this.getField("PKGPrice3").value = "$100.00";
         this.getField("PKGPrice4").value = "$295.00";
         this.getField("PKGPrice5").value = " ";
         this.getField("PKGPrice6").value = " ";
         this.getField("PKGPrice7").value = " ";
        
               break;
        
         case "Platinum Protection Package":
             this.getField("pkgdis").value = "Door Edge Guard(s) Protection";
         this.getField("pkgdis1").value = "Door Cups Protection";
         this.getField("pkgdis2").value = "Mirror Protection";
         this.getField("pkgdis3").value = "Hood Protection";
         this.getField("pkgdis4").value = "Bumper Protection";
         this.getField("pkgdis5").value = "Headlight(s) Protection";
         this.getField("pkgdis6").value = "Fender Protection";
         this.getField("pkgdis7").value = "Total Protection Package Value";
         this.getField("PKGPrice").value = "$50.00";
         this.getField("PKGPrice1").value = "$100.00";
         this.getField("PKGPrice2").value = "$45.00";
         this.getField("PKGPrice3").value = "$100.00";
         this.getField("PKGPrice4").value = "$275.00";
         this.getField("PKGPrice5").value = "$100.00";
         this.getField("PKGPrice6").value = "$50.00";
         this.getField("PKGPrice7").value = "$720.00";
        
               break;
        
        
          case " ":
               this.getField("pkgdis").value = " ";
         this.getField("PKGPrice").value = " ";
         this.getField("pkgdis1").value = " ";
         this.getField("pkgdis2").value = " ";
         this.getField("pkgdis3").value = " ";
         this.getField("pkgdis4").value = " ";
         this.getField("pkgdis5").value = " ";
         this.getField("pkgdis6").value = " ";
         this.getField("pkgdis7").value = " ";
         this.getField("PKGPrice").value = " ";
         this.getField("PKGPrice1").value = " ";
         this.getField("PKGPrice2").value = " ";
         this.getField("PKGPrice3").value = " ";
         this.getField("PKGPrice4").value = " ";
         this.getField("PKGPrice5").value = " ";
         this.getField("PKGPrice6").value = " ";
         this.getField("PKGPrice7").value = " ";
              break;
           //etc.
           }

        • 1. Re: Dropdown Menu Calculations
          kodiem13114922 Level 1

          I ended up using the built in calculations tab to calculate the numbers needed but then I also used the show / hide in java script. Proablly not the cleanest but it works here is the code used

           

          this.getField("Addons").display = event.value=="Standard Protection Package #1" ? display.visible : display.hidden;


          this.getField("Addons2").display = event.value=="Standard Protection Package #2" ? display.visible : display.hidden;


          this.getField("Addons3").display = event.value=="Premium Protection Package" ? display.visible : display.hidden;


          this.getField("Addons4").display = event.value=="Platinum Protection Package" ? display.visible : display.hidden;

           

          this.getField("NewMSRP").display = event.value=="Standard Protection Package #1" ? display.visible : display.hidden;


          this.getField("NewMSRP2").display = event.value=="Standard Protection Package #2" ? display.visible : display.hidden;


          this.getField("NewMSRP3").display = event.value=="Premium Protection Package" ? display.visible : display.hidden;


          this.getField("NewMSRP4").display = event.value=="Platinum Protection Package" ? display.visible : display.hidden;