• Resolved Jambena

    (@jambena)


    I have a calculated field: fieldname1 and a HTML content-field.

    I want the HTML content field to display a different link depending on the result of fieldname1.

    I’ve tried this:

    <script type=”text/javascript”>
    (function(){

    if (fieldname1 == “”) return “”;

    var link = document.getElementById(“link”)

    if(fieldname1 < 500) return link.innerHTML=”Under 500″;
    else if(fieldname1 > 500) return link.innerHTML=”Over 500″;

    })();
    </script>

    <div id=”link”></div>

    As soon as i put an if-statement and i mention ‘fieldname1’ in it, fieldname1 stops displaying anything. And also I know that the link will not change because I don’t call the actual link in the method, but the issue i want support on is rather why calculated field stop working when i refer to it from the method?

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @jambena

    I’ll try to describe the process with a hypothetical example, assuming that if the fieldname1 is lesser than 500 you want to include the link:

    <a href="https://yourwebsite.com/page-a">Under 500</a>

    and the link:

    <a href="https://yourwebsite.com/page-b">Over 500</a>

    if fieldname1 is over 500.

    – First, insert a “HTML Content” field in the form with the following tag as its content:

    
    <div id="link"></div>
    

    – Insert a calculated field in the form, to be used as auxiliary (so, you can tick the checkbox for hiding the field from the public form), with the following equation:

    
    (function(){
    var  e = jQuery('#link');
    
    if (fieldname1|r == ''){ e.html(''); return;}
    if(fieldname1 < 500) e.html('<a href="https://yourwebsite.com/page-a">Under 500</a>');
    else e.html('<a href="https://yourwebsite.com/page-b">Over 500</a>');
    
    })()
    

    and that’s all.
    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Field stops displaying results when mentioned’ is closed to new replies.