• Resolved muzicutza81

    (@muzicutza81)


    How can I include the text or the value of another field into an HTML Content field? I tried the following without success:
    “You have selected <%fieldname2_text%> as the closest equipment to your property”
    “Based on your selections, we estimate your total cost to be $<%fieldname22_value%>. Please note ….”

    Thanks in advance for your assistance!

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

    (@codepeople)

    Hello @muzicutza81,

    The fields’ tags can be used only with the notification emails and thank you pages, but not with the forms. In the forms the process would be different and requires some of code. Actually, would be better if you send me the URL to the page where the form is inserted to identify the fields: fieldname2 and fieldname22

    The process would be as follows:

    – Enter into the content of the “HTML Content” field a div tag with an unique class name where be shown the text:

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

    – Insert a calculated field as auxiliary with the following equation:

    
    (function(){
    jQuery('.result-here').html('You have selected '+fieldname2+' as the closest equipment to your property<br>Based on your selections, we estimate your total cost to be $'+fieldname22+'. Please note …');
    })()
    

    Note: As this calculated field is used as an auxiliary field, it is not relevant in the form’s interface, so, you should tick the checkbox: “Hide Field From Public Page” in its properties.

    Best regards.

    Thread Starter muzicutza81

    (@muzicutza81)

    Thank you. Just a quick note for anyone else that might need to accomplish this also; I had to change the suggested code for the calculated field to return a variable as described in another support post:

    (function(){
    var equipment = fieldname2;
    jQuery(‘.equipment-selected’).html(equipment);
    return equipment;
    })()

    Then added an HTML content field and included a span (instead of a div) with the class of equipment-selected:

    “You identified <span class=”equipment-selected” style=”font-weight:bold;” /> as the nearest piece of equipment…”

    Thank you for the assistance! This works! Any plans on simplifying how field values are included in HTML content in the near future?

    Plugin Author codepeople

    (@codepeople)

    Hello @muzicutza81,

    Actually, with the plugin you can use the javascript code you want, for example, the previous code can be implemented completely into the “HTML Content” field, without using any additional calculated fields, as follows:

    – The following code would be inserted into the content of the “HTML Content” field:

    
    <span class="equipment-selected"></span>
    <script>
    jQuery(document).on('change', '[id*="fieldname2_"]', function(){jQuery('.equipment-selected').html(this.value);});
    </script>
    

    In effect, there are other alternatives.
    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Include selected field text or value in another field’ is closed to new replies.