# Script inside FAQ

**URL:** <https://community.elfsight.com/t/script-inside-faq/109400>\
**Category:** Customization\
**Tags:** faq\
**Created:** [March 26, 2025, 10:34am UTC](https://community.elfsight.com/t/script-inside-faq/109400 "2025-03-26T10:34:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 26, 2025, 10:34am UTC](https://community.elfsight.com/t/script-inside-faq/109400/1 "2025-03-26T10:34:38Z")

</div>

Hi

I need to insert a script showing some football statistics in the FAQ widget as an answer.  
It saves the script but doesn’t show it

 ![Skærmbillede 2025-03-26 113220](https://us1.discourse-cdn.com/flex020/uploads/elfsight/original/3X/f/9/f99e2c669c2520443e75e5cae51aa5472e7432a8.png)

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 26, 2025, 11:40am UTC](https://community.elfsight.com/t/script-inside-faq/109400/3 "2025-03-26T11:40:56Z")

</div>

Hi there, @Kasper_Skov_Jensen 👋

The thing is that the Custom JS codes work only upon widget installation, not in preview mode. However, I also see some validation errors there:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/elfsight/original/3X/0/7/07ac5453f6e13ea17af1194ce38b0e5c5562596b.png)

Could you please elaborate on your use case and describe how this script should work? Do I get it right that you’d like to pull some statistics from a specific source?

---

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 26, 2025, 12:08pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/4 "2025-03-26T12:08:20Z")

</div>

Hi Max

Thanks for the reply.

I can’t get it to work on live sites either

The usecase is this: I have created the FAQ widget like this: [https://c0c49d93469b4582a18f6ed24c1633bc.elf.site](https://c0c49d93469b4582a18f6ed24c1633bc.elf.site)

In this example the questions are headlines about relevant statistics about Premier League.

The answer should be a script showing the table, goal scores etc.

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 26, 2025, 1:20pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/5 "2025-03-26T13:20:40Z")

</div>

Got it, thanks!

We’ve added this code to the answer HTML section (view Code Editor mode) for the Table question:

```auto
<div id="js-statorium-widget-638"></div>

<img style="display: none" src="x" 
onerror='(function(el){ 
    const script = document.createElement("script");
    script.src = "https://statorium.com/components/com_statoriumwidgets/assets/js/widget.js";
    script.type = "text/javascript";
    script.id = "js-statorium-id-638";
    document.body.appendChild(script);
    
    const widgetContainer = document.createElement("div");
    widgetContainer.id = "js-statorium-widget-638";
    document.body.appendChild(widgetContainer);
    
    script.onload = function() {
        const jsStatoriumWidgetClone = Object.assign({}, jsStatoriumWidget);
        jsStatoriumWidgetClone.setOptions({
            targetId: "js-statorium-widget-638",
            widgetID: 638,
        });
        jsStatoriumWidgetClone.render();
    };
})(this);'
/>

```

  

 ![image](https://us1.discourse-cdn.com/flex020/uploads/elfsight/original/3X/6/c/6c280fa4e6a520733e5c8af003b460432034d179.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/elfsight/original/3X/6/4/64d761040e146de8300715894365d5b082eec6d8.png)

  

If you like the result, please remove your script from the Custom JS section and publish changes 🙂

---

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 26, 2025, 2:02pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/6 "2025-03-26T14:02:32Z")

</div>

Hi again

It looks great, but I’m not sure how to do it and replicate it with other statistics from the same provider. Maybe you could write it out, step by step?

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 26, 2025, 2:16pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/7 "2025-03-26T14:16:49Z")

</div>

To identify what values should be changed in the code, we need a code pulling this (new) statistic from your provider. Could you please provide me with it?

---

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 26, 2025, 2:18pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/8 "2025-03-26T14:18:55Z")

</div>

Here is anorther one:

```auto
<div id="js-statorium-widget-648"></div>

<script>
    (function(doc, tag, id){
        let js = doc.getElementsByTagName(tag)[0];
        if (doc.getElementById(id)) {return;}
        js = doc.createElement(tag); js.id = id;
        js.src = "https://statorium.com/components/com_statoriumwidgets/assets/js/widget.js";
        js.type = "text/javascript";
        doc.body.appendChild(js);
    }(document, 'script', 'js-statorium-id-648'));
    window.addEventListener("load", function() {
        const jsStatoriumWidgetClone = Object.assign({}, jsStatoriumWidget);
        jsStatoriumWidgetClone.setOptions({
            targetId: "js-statorium-widget-648",
            widgetID: 648
        });
        jsStatoriumWidgetClone.render();
    });
</script>

```

Just a heads up: I have a lot of them 😄

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 26, 2025, 2:40pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/9 "2025-03-26T14:40:02Z")

</div>

Here is the code for the new statistics:

```auto
<div id="js-statorium-widget-648"></div>

<img style="display: none" src="x" 
onerror='(function(el){ 
    const script = document.createElement("script");
    script.src = "https://statorium.com/components/com_statoriumwidgets/assets/js/widget.js";
    script.type = "text/javascript";
    script.id = "js-statorium-id-648";
    document.body.appendChild(script);
    
    const widgetContainer = document.createElement("div");
    widgetContainer.id = "js-statorium-widget-648";
    document.body.appendChild(widgetContainer);
    
    script.onload = function() {
        const jsStatoriumWidgetClone = Object.assign({}, jsStatoriumWidget);
        jsStatoriumWidgetClone.setOptions({
            targetId: "js-statorium-widget-648",
            widgetID: 648,
        });
        jsStatoriumWidgetClone.render();
    };
})(this);'
/>

```

  

The code is the same as in the previous case, we’ve just replaced the number of the table with the statistics (638 was replaced with 648):

 ![image](https://us1.discourse-cdn.com/flex020/uploads/elfsight/original/3X/c/3/c355dad60d8e291523b5c35f80738433e060e011.png)

  

Please let me know if this explains things or if you have any questions left 🙂

---

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 26, 2025, 3:19pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/10 "2025-03-26T15:19:54Z")

</div>

Thanks for amazing support!

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 26, 2025, 3:21pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/11 "2025-03-26T15:21:07Z")

</div>

You’re always welcome 😉

In the meantime, we’d like to invite you to join our new challenge, where you can win **3 FREE months** for your subscription. Check the details and participate 🙂 - [March Challenge: Share your results with Elfsight & win 3 FREE months!🚀](https://community.elfsight.com/t/march-challenge-share-your-results-with-elfsight-win-3-free-months/105950)

---

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 27, 2025, 8:46am UTC](https://community.elfsight.com/t/script-inside-faq/109400/12 "2025-03-27T08:46:42Z")

</div>

Hi @Max

I just realized that the “answers” in my FAQ widget sometimes doesn’t expand completely first time the “question” is clicked. Is there a way to fix it?

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 27, 2025, 11:05am UTC](https://community.elfsight.com/t/script-inside-faq/109400/13 "2025-03-27T11:05:15Z")

</div>

Hi @Kasper_Skov_Jensen 👋

I’ve checked the widget and the expand option is working fine for me:

  

If the issue still persists on your end, please send me a video screencast of what you see 🙏

---

<div class="post-metadata">

**Author:** ![Martin1](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@Martin1](https://community.elfsight.com/u/Martin1)\
**Post date:** [March 27, 2025, 5:27pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/14 "2025-03-27T17:27:37Z")

</div>

Hi Kasper  
I’m a big Bournemouth fan, and Fantasy Football player. I’m curious about how the end result looks and where you have put it. Are you happy to share a URL?  
Martin

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [March 27, 2025, 6:06pm UTC](https://community.elfsight.com/t/script-inside-faq/109400/15 "2025-03-27T18:06:45Z")

</div>

@Martin1 Wow, one more football fan here 🤩

Nice season for Bournemouth by the way and Kluijvert especially. Can’t forget their game against Arsenal in October (cause I am an Arsenal fan 😁)

---

<div class="post-metadata">

**Author:** ![Kasper\_Skov\_Jensen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/kasper_skov_jensen/32/22504_2.png) [@Kasper\_Skov\_Jensen](https://community.elfsight.com/u/Kasper_Skov_Jensen)\
**Post date:** [March 28, 2025, 10:35am UTC](https://community.elfsight.com/t/script-inside-faq/109400/16 "2025-03-28T10:35:07Z")

</div>

Hi Martin

I’m happy to share the link next week, when we are live with the content. 🚀

Hav a great weekend
