Support » Plugin: Calculated Fields Form » return a Text value from a calculation

  • Resolved metanoia77



    I need to set that to a Text value based on a number

    Pseudo code:

    If field21 > 100 return “Complete”;

    If field21 < 50 return “Incomplete”;

    now I was thinking of setting up 2 “hidden from user fields”

    field25 initial value complete
    field26 initial value incomplete

    and using the Pseudo code to return fieldnames with default values of complete and incomplete ??

    anyway can I return text ? if so how ty πŸ™‚

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author codepeople



    By default the calculated field only accepts numeric values, and texts with date format, but if you want accept texts like “Complete” or “Incomplete”, you should modify the validation rules in the module_public.js file, located in “/wp-content/plugins/calculated-fields-form/js/modules/01_mathematical_logical/public/module_public.js”

    1. Open the module_public.js file in the text editor your choice.

    2. Go to the snippet of code:

    return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\d{4}/.test( v );

    and modify it like follow:

    return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\d{4}/.test( v ) || /complete|incomplete/i.test( v );

    Best regards.


    btw now i have my form – its working perfectly – but I cannot use <%info%>
    as the contact details are at the bottom – I moved them to the top and also formatting the email as a HTML Table etc ..(looks really pretty πŸ™‚ LoL)

    so I would like to add the “Include additional information” is there a <%IP addr%> or <%add-info%> ???

    really great plugin !!! so versatile – beats the socks off other forms πŸ™‚

    I even found a way to add the company logo πŸ™‚ so cooooooool !!!

    Plugin Author codepeople



    To send additional information, that is not collected by the forms, will require customize the plugin’s code.

    Specifically the cp_calculatedfieldsf.php file, around the line number 966, above the snippet of code:

    foreach ($to as $item)
    if (trim($item) != ”)
    wp_mail(trim($item), $subject, $message,
    “From: \”$from_1\” <“.$from_1.”>\r\n”.
    ($replyto!=”?”Reply-To: \”$replyto\” <“.$replyto.”>\r\n”:”).
    “X-Mailer: PHP/” . phpversion(), $attachments);

    For example, using the code:

    $message .= ‘
    IP Address: ‘.$_SERVER[‘REMOTE_ADDR’];

    Best regards.

    Thanks – I will try that πŸ™‚ Im just amazed how cool you guys are – this is my #1 plugin I wish I could give you 10 stars. I am gonna try to get more of my clients on board πŸ™‚

    Tobias A.



    I need to set the follow code to a text value based on a number:

    if(fieldname4==’1′) return ‘Liter’;
    if(fieldname4==’2′) return ‘mΒ³’;
    if(fieldname4==’3′) return ‘kg’;
    if(fieldname4==’4′) return ‘Ster’;
    if(fieldname4==’5′) return ‘kg’;

    How can i get that?

    I read the Text up there and put a javascript into module_public.js:
    return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\d{4}/.test( v ) || /Liter|mΒ³|kg|Ster/i.test( v );

    ThankΒ΄s for help!

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘return a Text value from a calculation’ is closed to new replies.