• Resolved otaviof

    (@otaviof)


    not sure if that’s been answered so I apologize in advance for any redundancy.

    I want to display some html when certain value is achieved/

    I was able to do a calculated field with a function like this:

    (function(){
    if(fieldname9 > 10) return ‘Congratualtions!’
    })();

    But this only echoes inside the field. I would like to echo a lot more text than within a single-line field. Maybe a whole <div> Is it possible to achieve that out-of-the-box?

    https://ww.wp.xz.cn/plugins/calculated-fields-form/

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes of course, that’s possible, but you need to use some tricks. I’ll try to explain the process with an example:

    1. Inserts a “HTML Content” field in the form, and enters in the attribute: HTML content, the tags: <div id=”myfield”></field>

    2. Finally, modifies the equation associated to the calculated field as follows:

    (function(){
    if(fieldname9 > 10) jQuery('#myfield').html( '<strong>Congratulations!</strong>' );
    })()

    Now, you simply should use the tags you prefer to display in the “myfield” field.

    and that’s all.

Viewing 1 replies (of 1 total)

The topic ‘using function to echo an paragraph.’ is closed to new replies.