Zero coding experience. I would like to generate 100+ quotes randomly on click of button.
With each click, new random message is to be displayed.
Appreciate any help. Support articles, sample code snippet or any reference link… Thanks in advance.
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();
}
@gelecegiyazmak Thanks for the code. will try and revert back for further doubts, if any