Thank you @russian-dima ! Update to say the following code works:
let allUrls = [
'https://www.mehelle.org/listpage/MurtuzaMuxtarov15',
'https://www.mehelle.org/listpage/AlovsatQuliyev45',
'https://www.mehelle.org/listpage/AlovsatQuliyevDalan2',
'https://www.mehelle.org/listpage/AlovsatQuliyevDalan3'
];
export function button9_click(event) {
let randomIndex = Math.floor(Math.random() * (allUrls.length - 1));
$w('#button9').link = allUrls[randomIndex];
wixLocation.to($w("#button9").link);
}
At this point I could technically accomplish my goal by putting in the URLs for all of my dynamic pages in the ‘allUrls’ section, however, that would make this section of code over 400 lines long and difficult to update. What would be great would be to somehow set ‘allUrls’ to equal the field in my collection that houses all these URLs and have it draw from that. I’ve tried to use a wixData query to do this, but haven’t had luck so far. I was messing around with variations of this:
let allUrls = [
wixData.query("listpage")
.contains("ListPageLink", "list")
.find()
.then()
];
but I know its incomplete, I’m just not sure how to make the results connect to the button as a proper URL. Any ideas on this would be greatly appreciated, in the meantime at least the other way works, though I’m sure a cleaner version is possible.