# problem $w() is not a function

**URL:** <https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [June 1, 2020, 5:09pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219 "2020-06-01T17:09:45Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 2, 2020, 3:03pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/21 "2020-06-02T15:03:45Z")

</div>

if in database the record add 3 équipements, i want to show 3 icons …for example. I have just made a test page and that is works but not works in “entreprises francophones detail”………test page is : [https://editor.wix.com/html/editor/web/renderer/edit/fa9ca072-2b07-4274-8cf8-810116b786cc?metaSiteId=54ba3451-ea8f-467c-a640-67e0b290e628&editorSessionId=6a6b62d7-9bb6-40a6-b91b-6cff4a9200f4&referralInfo=dashboard](https://editor.wix.com/html/editor/web/renderer/edit/fa9ca072-2b07-4274-8cf8-810116b786cc?metaSiteId=54ba3451-ea8f-467c-a640-67e0b290e628&editorSessionId=6a6b62d7-9bb6-40a6-b91b-6cff4a9200f4&referralInfo=dashboard)

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2020, 7:14am UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/22 "2020-06-03T07:14:31Z")

</div>

Where is the test page? I don’t see it.

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 8:15am UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/23 "2020-06-03T08:15:26Z")

</div>

Sorry here the page [https://editor.wix.com/html/editor/web/renderer/edit/fa9ca072-2b07-4274-8cf8-810116b786cc?metaSiteId=54ba3451-ea8f-467c-a640-67e0b290e628&editorSessionId=66df80de-4e0b-47c1-ab05-535cc277a735&referralInfo=dashboard](https://editor.wix.com/html/editor/web/renderer/edit/fa9ca072-2b07-4274-8cf8-810116b786cc?metaSiteId=54ba3451-ea8f-467c-a640-67e0b290e628&editorSessionId=66df80de-4e0b-47c1-ab05-535cc277a735&referralInfo=dashboard)

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2020, 8:18am UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/24 "2020-06-03T08:18:04Z")

</div>

The Editor URL doesn’t open up at the correct page. Please tell me which page.

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 11:47am UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/25 "2020-06-03T11:47:52Z")

</div>

Sorry good page is “Entreprises Francophones (Nom)”

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2020, 1:47pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/26 "2020-06-03T13:47:08Z")

</div>

For your test page, this should work for you:

```javascript
import wixData from 'wix-data';

$w.onReady(function () {
   $w("#dynamicDataset").onReady(async () => {
   let num = $w("#dynamicDataset").getCurrentItem().equipements.length;
 for (var i = 0; i < num; i++) {
 let rech = $w("#dynamicDataset").getCurrentItem().equipements[i]
 let result2 = await wixData.query("Equipements")
                .contains("title", rech)
                .find()
            $w(`#act${i}`).src = result2.items[0].icon;
            $w(`#act${i}`).show();
        }
    });
});

```

You should realize, that although the above code worked for me, it wasn’t very fast. I would suggest that you keep all of the images in an array or a JSON object in a file in the site’s Public folder (you can see that in the Site structure panel on the left side of the Editor). Then, instead of a doing a database query for each icon, you can do a simple code lookup which is much faster.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 2:15pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/27 "2020-06-03T14:15:32Z")

</div>

OK thank you very much…this is the test page so why it does not works in “Entreprises francophones detail” ? For line $w ( `#act${i}` ). show ()

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2020, 2:30pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/28 "2020-06-03T14:30:02Z")

</div>

What is the problem with that line? Are you getting an error? Or doesn’t the image show?

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 2:31pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/29 "2020-06-03T14:31:57Z")

</div>

@yisrael-wix i have tgis error : $w is not a function

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2020, 3:20pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/30 "2020-06-03T15:20:46Z")

</div>

@fredericmassard I’m sorry, but there’s something in your code that is causing the problem. but I can’t find it. Your code is just too complex for me to rewrite it. Your code had a number of problems and you will need to redo your code to conform to the way that I wrote it for your test page.

Make sure you use the dataset’s [onReady() event handler](https://www.wix.com/corvid/new-reference/wix-dataset/dataset/onready) as I did in my code.  
Also, you should use await for the database queries. Otherwise, you will need to change the loop to handle all of the returned Promises together - Promise.all().

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 3:31pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/31 "2020-06-03T15:31:16Z")

</div>

Array? Json ? I don t know how to do this…

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 3:31pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/32 "2020-06-03T15:31:32Z")

</div>

@yisrael-wix OK thanks a

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2020, 4:09pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/33 "2020-06-03T16:09:52Z")

</div>

@fredericmassard Don’t worry. It’s something you can learn someday. It’ll make the display of the icons faster.

---

<div class="post-metadata">

**Author:** ![fredericmassard](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@fredericmassard](https://forum.wixstudio.com/u/fredericmassard)\
**Post date:** [June 3, 2020, 4:12pm UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/34 "2020-06-03T16:12:13Z")

</div>

@yisrael-wix a tutorial exist ?

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 4, 2020, 7:29am UTC](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219/35 "2020-06-04T07:29:21Z")

</div>

@fredericmassard

Here’s an excellent Javascript tutorial: [https://javascript.info](https://javascript.info)

For information on arrays, see this section: [https://javascript.info/array](https://javascript.info/array)  
For information on Objects, see this section: [https://javascript.info/object](https://javascript.info/object)  
For information on JSON: [https://javascript.info/json](https://javascript.info/json)

You can find tons more with an Internet search.

Good luck

[Previous page](https://forum.wixstudio.com/t/problem-w-is-not-a-function/20219.md?page=1)
