Randomly display items in a repeater?

I am on the hunt for either some code I could insert or a way that I can randomly display items in the repeater option. I have a wedding directory and I want the business listings order to change every time someone goes on the page. So the same items are not always up the top. Thought some clever person out there would know how to do this. Thank you in advance.

Hello,

here you will find a little example how to generate something RANDOM.
https://russian-dima.wixsite.com/meinewebsite/random-numbers-strings

For example you could generate random numbers between 1-99 and then use them like index-numbers in your database.

For example your first row “title”:

Index

1
2
3
4
5
…and so on.

You generate a number when page loads

$w.onReady(function () {  START GENERATOR-FUNCTION HERE   });
function myGENERATORFUNCTION (parameter) { GENERATE RANDOM NUMBER (1-99) for example }

Then when you have your random number for example " 55" you search the row-55 in your DATABASE…

$w("#myDataset").getItems(55, 1)
  .then( (result) => {
    let items = result.items;
    let totalCount = result.totalCount;
    let offset = result.offset;
  } )
  .catch( (err) => {
    let errMsg = err.message;
    let errCode = err.code;
  } );

Of course, the [“55”] has to be a variable (this is just an example).
Something like this…

$w("#myDataset").getItems(GeneratedNumber,1)

And at least you have to get the right colum where you store the related data
For example, if you want to get all data from the first column → “title”…

let items = result.items;
console.log(items.title) //this should show you the row of the current generated RANDOM-NUMBER, at the "title"-column.

There are surely also other methods how to do that.:grin: