• Resolved super-admin-2014

    (@super-admin-2014)


    Hi,

    I want to use a shortcode from another plugin, inside a HTML field that appears when a value in another field is above 0.

    So for example, when the value of the calculated field is 20, the application that is being called by a shortcode is shown. However, what is happening now is that it is just showing the shortcode as text (wrapped in quotations).

    Any ideas on how to do this? I’ve read about using do_shortcode but not sure what to do with that.

    https://www.ads-software.com/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    In the current version of the plugin are not accepted shortcodes from other plugins into the fields contents, because the majority of shortcode insert javascript code or a format that can break the code of the forms.

    Could you indicate the shortcode that want to insert, and how will be used, please?

    Best regards.

    Thread Starter super-admin-2014

    (@super-admin-2014)

    Hi,

    Thanks for the response. I wanted to use a submission form that includes Name, Email and Number and then allows the user to submit that information to us via E-mail. However, I only want this form to appear depending on the value in the calculated field of your plugin. Does that make sense?

    Thanks!

    Plugin Author codepeople

    (@codepeople)

    Hi,

    My recommendation in this case is inserting the shortcode in the same page, as another shortcode, separated of our form, but into a <DIV> tag, as follows:

    <div id="secondForm" style="display:none;">[THE_SECOND_SHORTCODE_HERE]</div>

    Tip: To insert HTML tags in the content of a post/page, you should activate the “Text” tab, or the symbols "<", and ">", are converted in "<", and ">", respectively.

    Now, as part of the equation associated to the calculated field you can use the following line of code:

    jQuery(‘#secondForm’).show();

    For example, if your current equation is: fieldname1+fieldname2, and you want to display the second form only if the result is bigger than 10, you should modify the equation as follows:

    (function(){
    var r = fieldname1+fieldname2;
    if(r>10) jQuery('#secondForm').show();
    else jQuery('#secondForm').hide();
    })()

    Best regards.

    Thread Starter super-admin-2014

    (@super-admin-2014)

    Hi,

    Thanks so much for your help! WHere would I put the line:

    jQuery(‘#secondForm’).show();

    Regards.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    The snippet of code should be included as part of the equation, associated to the calculated field that decides if display the second form or not.

    As was explained in the previous entry with an example. Assuming that the current equation associated to a calculated field is: fieldname1+fieldname2, and you want to display the second form only if the result of previous mathematical operation is bigger than 10, you should modify the equation as follows:

    (function(){
    var r = fieldname1+fieldname2;
    if(r>10) jQuery('#secondForm').show();
    else jQuery('#secondForm').hide();
    })()

    The previous equation creates a variable, called “r”, with the mathematical operation: fieldname1+fieldname2, and checks the value of “r” with a conditional statement, and displays or hides the second form if the condition is satisfied or not.

    Best regards.

    Thread Starter super-admin-2014

    (@super-admin-2014)

    Sorry, that was a silly question as I realised what I had to do. When I use the code in to the calculated field, it works but the calculated field is not showing the value that is calculated.

    My current equation was:

    IF( OR(fieldname20,fieldname21), prec( (fieldname20+fieldname21*fieldname9)-(fieldname3==’London’?9.45:5.83)*fieldname9,2), 0 )

    Now, when I put the values into fieldname9 and fieldname20 (or 21), it will show the email submission div, but the calculated field will not show a vale.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Please, replace your current equation with the following one:

    (function(){
    if( OR(fieldname20,fieldname21) )
    {
    jQuery('#secondForm').show();
    return PREC( (fieldname20+fieldname21*fieldname9)-(fieldname3=='London'?9.45:5.83)*fieldname9,2);
    }
    jQuery('#secondForm').hide();
    return 0;
    })()

    Best regards.

    Thread Starter super-admin-2014

    (@super-admin-2014)

    Superb! Thank you so much.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcode inside a field?’ is closed to new replies.