Here is an example similar to what you want. You can see the example by clicking View example. You can see the codes and other parts by clicking Edit now. I wrote the codes you need to use.
var randomPhrases = [
“You’re my definition of perfect.” ,
“You keep me safe, I’ll keep you wild.” ,
“You’re the macaroni to my cheese.” ,
“I pinky promise I will love you forever.” ,
“Stay Safe. Eat Cake.” ,
“Veni, Vidi, Vici.”
];
// Set a random custom text when the random button is clicked.
export function randomButton_click(event, $w) {
// Choose a random index value.
const randomIndex = Math .floor( Math .random() * randomPhrases.length);
// Set the custom text on the product image to the chosen random text.
$w( ‘#customText’ ).text = randomPhrases[randomIndex];
// Set the custom text in the custom text input element to the chosen random text.
$w( ‘#textInput’ ).value = randomPhrases[randomIndex];
// Show the custom text layer on the product image.
$w( ‘#customText’ ).show();
}