Title: java calculated field form
Last modified: June 18, 2018

---

# java calculated field form

 *  Resolved [denisa](https://wordpress.org/support/users/elenadenisa/)
 * (@elenadenisa)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/)
 * Hi there,
    Can someone help me, pls? I can’t get a function to return the value
   on a calculaiton field. I have four fields: – nightly rate $ – fieldname 2 – 
   days fieldname6 – years fieldname11 – inflation fieldname7
 * …and a calclation field fieldname12
 * I have this function
    function () { day = fieldname2; days = fieldname6; years
   = fieldname11; rate = fieldname7; total = 0; temp = 0; price=day*days;
 * for(var i = 1; i <= years; i++){
    price=calprice(price,rate) total=total+price;
 * tf = fieldname12; tf.setValue(parseInt(total) + ‘$’);
    };
 * and it’s not returning anything.
 * Can you help me pls? What I’m doing wrong. I’m moving this and it doesn’t want
   to work here.
    Thank you for your time
    -  This topic was modified 8 years, 1 month ago by [denisa](https://wordpress.org/support/users/elenadenisa/).
    -  This topic was modified 8 years, 1 month ago by [denisa](https://wordpress.org/support/users/elenadenisa/).
    -  This topic was modified 8 years, 1 month ago by [denisa](https://wordpress.org/support/users/elenadenisa/).
    -  This topic was modified 8 years, 1 month ago by [denisa](https://wordpress.org/support/users/elenadenisa/).
    -  This topic was modified 8 years, 1 month ago by [denisa](https://wordpress.org/support/users/elenadenisa/).

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

 *  [phixate](https://wordpress.org/support/users/phixate/)
 * (@phixate)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/#post-10412746)
 * I’m a complete noob so this might not work but I have a function that is structured
   like this and it works for me. Not sure if the opening parenthesis makes a difference
   in this plugin but I pulled this syntax directly from their documentation.
 * (function(){
 * if(fieldname10 == 12)
    return prec(fieldname1*1.4,2); if(fieldname10 == 24 ) 
   return prec(fieldname1*1.6,2); if(fieldname10 == 36) return prec(fieldname1*1.8,2);
 * })();
    -  This reply was modified 8 years, 1 month ago by [phixate](https://wordpress.org/support/users/phixate/).
 *  Thread Starter [denisa](https://wordpress.org/support/users/elenadenisa/)
 * (@elenadenisa)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/#post-10412768)
 * Hi [@phixate](https://wordpress.org/support/users/phixate/),
    Thank you for your
   post, but mine is a for loop, not a conditional if statement,a nd it will not
   work. I’m not a pro also, so I’m sure that somewhere I miss something. Thank 
   you anyway for trying to help me.
 *  [phixate](https://wordpress.org/support/users/phixate/)
 * (@phixate)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/#post-10412813)
 * Well, I tried! Hope you get it resolved.
 *  Thread Starter [denisa](https://wordpress.org/support/users/elenadenisa/)
 * (@elenadenisa)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/#post-10414214)
 * I’ve fixed the code, but I have a very simple issue now, and to tired to be able
   to get it work. I’ll open a new thread
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/#post-10415990)
 * Hello ,
 * There are some errors in your code, actually the equation’s structure should 
   be:
 *     ```
       (function(){
       })()
       ```
   
 * To allow it be evaluated immediately.
 * Second, there are many variables defined globally, and some semicolon symbols
   that were not included, and much more important, there is required a “return”
   instruction to return the result.
 * A possible equation would be:
 *     ```
       (function () {
       	var day = fieldname2,
       	days = fieldname6,
       	years = fieldname11,
       	rate = fieldname7,
       	total = 0,
       	temp = 0,
       	price = day * days;
   
       	for (var i = 1; i <= years; i++) {
       		price = calprice(price, rate);
       		total = total + price;
       	};
   
       	return PREC(total,2);
       })()	
       ```
   
 * Best regards.

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

The topic ‘java calculated field form’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form - AI Form Builder for WordPress - Contact, Payment, Quote, Quiz & More](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/)

 * 5 replies
 * 3 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/java-calculated-field-form/#post-10415990)
 * Status: resolved