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

    (@codepeople)

    Hello @emolotel

    If you are talking about to display the result of an equation to generate a format more natural, like: “You should to purchase XXXXXX items of the product.”

    There are two alternatives, you can insert into the “HTML Content” field the text and a tag where show the value:

    
    <p>You should to purchase <span class="result-here"></span> items of the product.</p>
    

    and then you can edit the equation as follows (assuming the original equation is fieldname1+fieldname2):

    
    (funciton(){
    var result = fieldname1+fieldname2;
    jQuery('.result-here').html(result);
    return result;
    })()
    

    or if you prefer, you should leave the equation as it is, and then, assign the value from the same “HTML Content” field (assuming the calculated field is the fieldname3)

    
    <p>You should to purchase <span class="result-here"></span> items of the product.</p>
    <script>
    jQuery(document).on('change', '[id*="fieldname3_"]', function(){jQuery('.result-here').html(this.value);});
    </script>
    

    Another alternative, if you want the “HTML Content” field be empty until the equation be evaluated, would be to generate completely the text into the equation or the onchange event, as follows:

    – Into the “HTML Content” field:

    
    <p class="result-here"></p>
    

    into the equation:

    
    (funciton(){
    var result = fieldname1+fieldname2;
    jQuery('.result-here').html('You should to purchase '+result+' items of the product.');
    return result;
    })()
    

    or with the second variant:

    
    <p class="result-here"></p>
    <script>
    jQuery(document).on('change', '[id*="fieldname3_"]', function(){jQuery('.result-here').html('You should to purchase '+this.value+' items of the product.');});
    </script>
    

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Html Content’ is closed to new replies.