Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter eyalnagar

    (@eyalnagar)

    ok thanks!

    Thread Starter eyalnagar

    (@eyalnagar)

    So you suspect that because there’s issues with the script i can’t load 2 in the same page? because if i load just 1 it works perfectly.. i didn’t really understand what exactly needs to be fixed i am not a developer unfortunately i got the script from ChatGPT. Can you elaborate about what needs to be fixed it the script in order to load 2 or more of it on the same page?

    Thread Starter eyalnagar

    (@eyalnagar)

    This is the script i’m trying to add in two different parts of the same page:

    <html>
    <head>
    <title></title>
    </head>
    <body>
    <h1></h1>
    <p id=”btcIlsRate”></p>
    
    <script>
    let btcUsdtRate;
    let exchangeRate;
    
    async function getBtcUsdtRate() {
    const response = await fetch(‘https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT’);
    const data = await response.json();
    btcUsdtRate = data.price;
    }
    
    async function getExchangeRate() {
    const response = await fetch(‘https://sheets.googleapis.com/v4/spreadsheets/1pD2OvlZGyGcXIApHXmBZUE0IPTD_bhdG0d14GBNWrhc/values/D2:D2?key=AIzaSyDZz8u5FEoQ4PW7P_TCdx2EqDPVY_Uo9tM’);
    const data = await response.json();
    exchangeRate = data.values[0][0];
    }
    
    function updateBtcIlsRate() {
    document.getElementById(‘btcIlsRate’).innerHTML = ${(btcUsdtRate * exchangeRate).toFixed(2)};
    }
    
    async function getRates() {
    await getBtcUsdtRate();
    await getExchangeRate();
    updateBtcIlsRate();
    }
    
    setInterval(getRates, 1000);
    </script>
    </body>
    </html>

    and i tried using elementor’s html element to add it, i tried through the wordpress’s html element, also tried to use HFCM and Code Snippet addons to create short codes to the script and implement but it didn’t work. also i tried to combine using the html element on wordpress or elementor and using a shortcode but that didn’t work..

    Thread Starter eyalnagar

    (@eyalnagar)

    This is the script i’m trying to add in two different parts of the same page:
    ‘`<html>
    <head>
    <title></title>
    </head>
    <body>
    <h1></h1>
    <p id=”btcIlsRate”></p>

    <script>
    let btcUsdtRate;
    let exchangeRate;

    async function getBtcUsdtRate() {
    const response = await fetch(‘https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT&#8217;);
    const data = await response.json();
    btcUsdtRate = data.price;
    }

    async function getExchangeRate() {
    const response = await fetch(‘https://sheets.googleapis.com/v4/spreadsheets/1pD2OvlZGyGcXIApHXmBZUE0IPTD_bhdG0d14GBNWrhc/values/D2:D2?key=AIzaSyDZz8u5FEoQ4PW7P_TCdx2EqDPVY_Uo9tM&#8217;);
    const data = await response.json();
    exchangeRate = data.values[0][0];
    }

    function updateBtcIlsRate() {
    document.getElementById(‘btcIlsRate’).innerHTML = ${(btcUsdtRate * exchangeRate).toFixed(2)};
    }

    async function getRates() {
    await getBtcUsdtRate();
    await getExchangeRate();
    updateBtcIlsRate();
    }

    setInterval(getRates, 1000);
    </script>
    </body>
    </html>
    `
    and i tried using elementor’s html element to add it, i tried through the wordpress’s html element, also tried to use HFCM and Code Snippet addons to create short codes to the script and implement but it didn’t work. also i tried to combine using the html element on wordpress or elementor and using a shortcode but that didn’t work..

    • This reply was modified 2 years, 2 months ago by eyalnagar.
Viewing 4 replies - 1 through 4 (of 4 total)