top of page

Forum Posts

Amber
Feb 26, 2020
In Coding with Velo
Hi, I need your help. Here's what I get import wixData from 'wix-data'; $w.onReady(function() { $w('#button1').onClick(toggleItems); $w("#text2").text = " "; }); function toggleItems() { $w('#dataset1').onReady(() => { let coin=$w("#dataset1").getCurrentItem().gCoin; if (coin===0) { toggleItems().stop(); } $w("#dataset1").setFieldValue("gCoin",coin-1); $w("#dataset1").save(); const ArrayList = ['item1','item2','item3','item4','item5']; const randomIndex = Math.floor(Math.random() * (ArrayList.length)); $w("#text2").text = ArrayList[randomIndex]; }); } If a random item from ArrayList was shown by $w("#text2").text=ArrayList[randomIndex];, I want to make remove the item from ArrayList forever. But I can get reach. I use splice() but it didn't work. It actually remove the item from ArrayList, but ArrayList has 5 item again when I re-run function toggleItems. So, I think I need to use database, but I don't know how to handle it well. When I searched about this problem, people said use wixData.query(). But I can't get anything. if I use wixData.query(), there is an error message: the collection doesn't exist. Is there anybody to help me?
0
2
364

Amber

More actions
bottom of page