• Resolved peti73

    (@peti73)


    Hi,

    i’ve made an API-call within a “HTML Content” field with your help:

    <script>
    fbuilderjQuery(document).one('cff-gotopage', function(){
        fbuilderjQuery.getJSON( 'https://api.metalpriceapi.com/v1/latest?api_key=[API_KEY]&base=USD&currencies=EUR,XAU,XAG', 
        function(data){
            fbuilderjQuery('[id*="fieldname3_"]').val(1/data['rates']['XAU']);
            ENABLEEQUATIONS(jQuery('[id*="cp_calculatedfieldsf_pform_"]'));
            EVALEQUATIONS(jQuery('[id*="cp_calculatedfieldsf_pform_"]'));
        });
    });
    </script>

    My problem is that my API-KEY is visible in the browsers element inspector with the whole script.
    Is there a method to HIDE this?

    A workaround could be to run this shortcode in a field: [metalpriceapi price_round=”2″]. Is that possible?

    Thanks!

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

    (@codepeople)

    Hello @peti73

    There are some alternatives:

    You can insert the shortcode you are referring to directly into the page and use the resulting code from the form.

    What is the resulting code from inserting the [metalpriceapi price_round="2"] shortcode?

    Or you can enable the SERVER_SIDE Equations add-on (Distributed with the Developer and Platinum versions of the plugin) and call it from the calculated field in the form:

    https://cff.dwbooster.com/blog/2018/10/01/server-side-equations

    Best regards.

    Thread Starter peti73

    (@peti73)

    Hi,

    [metalpriceapi price_round="2"] shortcode just gives a number, the actual price.
    Ie.
    1872.11

    Can i insert that shortcode in a field?

    Thanks!

    Thread Starter peti73

    (@peti73)

    < code > 1872.11 < /code >
    (without the spaces)

    Plugin Author codepeople

    (@codepeople)

    Hello @peti73

    In this case, you can insert the shortcode into a span tag with an unique id:

    <span id="my_number">[metalpriceapi price_round="2"]</span>

    And then, insert a calculated field in the form, and enter the following equation through its settings:

    jQuery('#my_number').text();

    Now, the calculated field has the number generated by the shortcode.

    Best regards.

    Thread Starter peti73

    (@peti73)

    Well, it works, but with this method i cannot put the API-call on Page 2 as it is outside the form.

    Maybe the SERVER_SIDE Equations add-on will do the trick.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hide script in html content or do shortcode’ is closed to new replies.