Title: Radio button calculation
Last modified: February 20, 2020

---

# Radio button calculation

 *  Resolved [rolbuk](https://wordpress.org/support/users/rolbuk/)
 * (@rolbuk)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/)
 * Hi,
    I have question on how to make shipping price calculation with radio button.
   fieldname1(Weight) fieldname2 radio button with 3 choice DHL, Fedex, UPS
 * DHL and UPS has static price 2.99, but FEDEX has price based on weight. How can
   I make calculation depending on the user’s radio button choice?
    Thanks!
    -  This topic was modified 6 years, 3 months ago by [rolbuk](https://wordpress.org/support/users/rolbuk/).

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12460467)
 * Hello,
 * There is a simple solution. For example, assuming FEDEX includes a factor per
   kg (for example: $1.5), and fieldname1 is the weight in kg.
 * First, enter as the values of choices in the Radio Buttons field (fieldname2):
   DHL, UPS and FEDEX, respectively.
 * and then, implement the equation associated to the calculated field as follows:
 *     ```
       (function(){
       if(fieldname2=='FEDEX')) return fieldname1*1.5;
       return 2.99;
       })()
       ```
   
 * or simply:
 *     ```
       IF(fieldname2=='FEDEX', fieldname1*1.5, 2.99)
       ```
   
 * Best regards.
 *  [martin136](https://wordpress.org/support/users/martin136/)
 * (@martin136)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12460529)
 * Set your calculation at the radio buttons to UPS 2.99, DHL 2.99, e.g. Fedex 1.50.
 * create a new field for “weight” which is only being displayed if the user chooses
   Fedex (dependency).
 * insert the dependency “weight” in your DHL,UPS,Fedex field at the radio buttons
   field unter the fedex entry.
 * set the range for values e.g. 1 to 30
 * Create an additional calculation field which is displayed only if Fedex is chosen.
 * You might want to see some calculation I just have created with radio buttons
   and lots of dependencies : [https://www.roller-aus-blech.de/vespa-blog/drehzahlrechner/](https://www.roller-aus-blech.de/vespa-blog/drehzahlrechner/)
    -  This reply was modified 6 years, 3 months ago by [martin136](https://wordpress.org/support/users/martin136/).
 *  Thread Starter [rolbuk](https://wordpress.org/support/users/rolbuk/)
 * (@rolbuk)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12460866)
 * Thanks you both.
    Codepeople there is additional price which calculated like 
   this if(fieldname1 <= 2) return 2.89; if(fieldname1 <= 3) return 3.39; if(fieldname1
   <= 4) return 3.89;
 * How can I connect these calculation? It should be something like this
    (function(){
   if(fieldname1 <= 2) return 2.89+(fieldname2==’FEDEX’); if(fieldname1 <= 3) return
   3.39+(fieldname2==’FEDEX’);
 * })()
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12460920)
 * Hello [@rolbuk](https://wordpress.org/support/users/rolbuk/),
 * The equation could be implemented as follows:
 *     ```
       (function(){
       if(fieldname2 != 'FEDEX') return 2.99;
       if(fieldname1 <= 2) return 2.89;
       if(fieldname1 <= 3) return 3.39;
       if(fieldname1 <= 4) return 3.89;
       })()
       ```
   
 * and that’s all.
 * Best regards.
 *  Thread Starter [rolbuk](https://wordpress.org/support/users/rolbuk/)
 * (@rolbuk)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12461024)
 * [@codepeople](https://wordpress.org/support/users/codepeople/) but it wouldn’t
   calculate both prices. I need formula which would show result of if(fieldname1
   <= 2) return 2.89; **+** if(fieldname2 != ‘FEDEX’) return 2.99;
    We very close
   to right formula:)
    -  This reply was modified 6 years, 3 months ago by [rolbuk](https://wordpress.org/support/users/rolbuk/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12461041)
 * Hello [@rolbuk](https://wordpress.org/support/users/rolbuk/)
 * I’m not totally sure of your equation’s description, but I guess you are referring
   to something like:
 *     ```
       (function(){
       var factor = IF(fieldname2 != 'FEDEX', 2.99, 0);
       if(fieldname1 <= 2) return 2.89+factor;
       if(fieldname1 <= 3) return 3.39+factor;
       if(fieldname1 <= 4) return 3.89+factor;
       })()
       ```
   
 * Best regards.
 *  Thread Starter [rolbuk](https://wordpress.org/support/users/rolbuk/)
 * (@rolbuk)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472597)
 * Hi,
    I think I found the right calculation, but it doesn’t work, could you please
   tell what is wrong with this formula? Thanks.
 * (function(){
    if((AND(fieldname11 == ‘Omniva’, fieldname2 <= 2) ) return 5.99;
   return 2.99; })()
 * Actually it explain the flow if fieldname11 is Omniva and fieldname <=2 result
   5.99, otherwise 2.99
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472631)
 * Hello [@rolbuk](https://wordpress.org/support/users/rolbuk/)
 * Your equation’s structure includes an extra open parenthesis into the conditional
   statement, furthermore the single quote symbols are invalid, but probably they
   where replaced by the text editor of this forum. The correct equation would be:
 *     ```
       (function(){
       if(AND(fieldname11 == 'Omniva', fieldname2 <= 2)) return 5.99; 
       return 2.99;
       })()
       ```
   
 * Best regards.
 *  Thread Starter [rolbuk](https://wordpress.org/support/users/rolbuk/)
 * (@rolbuk)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472697)
 * Thanks [@codepeople](https://wordpress.org/support/users/codepeople/) now it 
   works. But the next formula with fieldname <= 2 does not show right result. Anything
   wrong with this formula?
    (function(){ if(AND(fieldname11 == ‘Omniva’, fieldname2
   <= 1)) return 5.99; return 2.99; if(AND(fieldname11 == ‘Omniva’, fieldname2 <
   = 2)) return 6.99; return 2.99; })()
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472705)
 * Hello [@rolbuk](https://wordpress.org/support/users/rolbuk/)
 * The “return” instruction moves the execution outside the equation, so, the “return”
   instruction that is not controlled by the conditional statements should be inserted
   at the end only, or the second conditional statement would not be reached.
 *     ```
       (function(){
       if(AND(fieldname11 == 'Omniva', fieldname2 <= 1)) return 5.99;
       if(AND(fieldname11 == 'Omniva', fieldname2 <= 2)) return 6.99;
       return 2.99;
       })()
       ```
   
 * Best regards.
 *  Thread Starter [rolbuk](https://wordpress.org/support/users/rolbuk/)
 * (@rolbuk)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472832)
 * Okey, it works. The other problem is that above number 29, fieldname2 <= 30 return
   8.99, otherwise 0.
    How can I implement it into my formula below? Thanks!
 * (function(){
    if(AND(fieldname11 == ‘Omniva’, fieldname2 <= 1)) return 5.99; 
   if(AND(fieldname11 == ‘Omniva’, fieldname2 <= 2)) return 6.99; return 2.99; })()
    -  This reply was modified 6 years, 3 months ago by [rolbuk](https://wordpress.org/support/users/rolbuk/).
    -  This reply was modified 6 years, 3 months ago by [rolbuk](https://wordpress.org/support/users/rolbuk/).
    -  This reply was modified 6 years, 3 months ago by [rolbuk](https://wordpress.org/support/users/rolbuk/).
    -  This reply was modified 6 years, 3 months ago by [rolbuk](https://wordpress.org/support/users/rolbuk/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472848)
 * Hello [@rolbuk](https://wordpress.org/support/users/rolbuk/)
 * I’m sorry, but I cannot implement the users’ projects (forms or formulas) as 
   part of the support service. If you need that I implement your equations, you
   should request a custom coding service from my private website: [Customization](https://cff.dwbooster.com/customization)
 * Best regards.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Radio button calculation’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 12 replies
 * 3 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/radio-button-calculation/#post-12472848)
 * Status: resolved