Skip to main content
Participant
March 31, 2026
Question

Radio Button Calculation not working

  • March 31, 2026
  • 1 reply
  • 39 views

I have a form that calculates fees for a permit. Everything works perfect and calculates the total accurately.  My problem is that I have a radio button set up next to the total that is a simple yes/no. 

If yes is checked, it is supposed to double the total fee. 

If no is checked, the total fee should remain as is. 

I have tried every variation I can think of and read all the forums I can find. It seems like it should be extremely simple but I am stuck.  Any advice?

    1 reply

    Karl Heinz  Kremer
    Community Expert
    Community Expert
    March 31, 2026

    How are you calculating the total? What have you tried so far? Can you share the form? This can certainly be done, but the how depends on how you are doing your calculation. 

    Participant
    March 31, 2026

    Form attached. 

    The fee is calculated via this calculation:

    var A = this.getField("TotalFix").value;
    var B = this.getField("FixtureFee").value;
    var C = this.getField("PermitTransfer").value;

    if (A <= 3 ) event.value = 50;
    if (A >= 4 ) event.value = (A*B);
    if (A == 0 && C == 10)  event.value=10;
     

    The double fee portion, I have tried all sorts of different variations that I found online. The current calculation was one I found in a forum today and decided to try but failed. 

    It is the Total Fee Field in the top right corner. The double fee radio buttons are directly below it. 

    Karl Heinz  Kremer
    Community Expert
    Community Expert
    March 31, 2026

    When you work with JavaScript, it is important to keep track of the JavaScript console - this is where all JavaScript related errors would pop up. When I toggled the “Double Fee” checkbox, I got this in the console:
     


    ReferenceError: TF is not defined
    4:Field:Calculate

    This is an indication to what’s wrong: Somewhere, the variable TF is not defined. When I then checked the calculation script for your “Total Fee” field, I see this:
     

    if (this.getField("DF").value === "Yes") {
    this.getField("Total").value = (TF*2);
    } else {
    this.getField("Total").value = TF;
    }

    The variable TF is used without getting declared or initialized. I see that you have a field named TF at the bottom of the form, so I assume that’s where the not yet doubled fee is coming from. There were a couple other things I needed to correct to make this work. This should work as the calculation script for your “Total” field:
     

    var TF = this.getField("TF").value;
    if (this.getField("DF").value === "YES") {
    event.value = (TF*2);
    } else {
    event.value = TF;
    }

    As you can see, the value for the field that gets calculated is set by assigning to “event.value”, and the return code of your DF radio button group is case sensitive, so you need to check for “YES”.