SOLVED - Please help! - Code & instructions for a random 'name' generator (example pic attached)

Thank you in advance if anyone has any time to help me with this!
In brief, a page I need/others use, stopped working when connected to Wix & they say it’s impossible to get it working without recreating this page.
I previously coded it with PHP years ago when with JustHost.
After spending all day tearing my hair out I’ve lost interest in learning the Wix environment/Java/Databases & just want this specific page fixed for now :frowning:

AIM:
When a button is clicked it generates 2 words pulled at random from 2 lists. 1st word from list A + 2nd word from list B.

  • words don’t have to be removed from further clicks/no restrictions
  • List A has 133 entries so far, List B has 99 entries (if this helps)

WHAT I HAVE SO FAR:
The page is set up & the basic button is there via an addon HTML field to input UI code.
aModule.jsw exists - I assume this will need to contain string/array data? Let’s assume this is blank as I can’t make sense of any tutorials having not done any JS before, ever.

WHAT I NEED:
The code for both script & linking the button to this.
Idiot-proof clarification on where to paste these scripts!

Thank you so much in advance if anyone has time.

I am sorry but this seem a bit more complicated than a simple question. If you need to hire someone I would be glad to point you to some of the 10 skilled developers we have in our network.

The other solution would be for you to become a paying subscriber to wixshow.com and get support help from me that way.

Or wait here for someone having the time to help you freely. Time is everyones enemy now :slight_smile:

Thanks for replying Andreas! I may be able to donate/pay for help but as you say time is the enemy & didn’t realise this would be more complex as I’m a total beginner with JS - I’ve posted locally in community groups to see if someone can physically come & show me this, but wixshow.com looks good too so that may be my backup plan :slight_smile:

@faelourn I just think that everyone is so occupied that getting help with anything larger is hard now. But good luck and get back to me if it does not work.

If this is any help then here’s an example I found elsewhere doing exactly what I need so I’ve copied it exactly & how I’ve tried to ‘stuff it in’ to the Wix environment… unsuccessfully.

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
$w.onReady(function () {

});
export function button1_click(event, $w) {
	$('button1').click(function() {
    $('h2').text(randomEl(adjectives)+' '+randomEl(nouns));
    selectElementContents($('h2')[0]);
});

function randomEl(list) {
    var i = Math.floor(Math.random() * list.length);
    return list[i];
}

function selectElementContents(el) {
    var range = document.createRange();
    range.selectNodeContents(el);
    var sel = window.getSelection();
    sel.removeAllRanges();
    sel.addRange(range);
}

var adjectives = ["adamant", "adroit", "amatory", "animistic", "antic", "arcadian", "baleful", "bellicose", "bilious", "boorish", "calamitous", "caustic", "cerulean", "comely", "concomitant", "contumacious", "corpulent", "crapulous", "defamatory", "didactic", "dilatory", "dowdy", "efficacious", "effulgent", "egregious", "endemic", "equanimous", "execrable", "fastidious", "feckless", "fecund", "friable", "fulsome", "garrulous", "guileless", "gustatory", "heuristic", "histrionic", "hubristic", "incendiary", "insidious", "insolent", "intransigent", "inveterate", "invidious", "irksome", "jejune", "jocular", "judicious", "lachrymose", "limpid", "loquacious", "luminous", "mannered", "mendacious", "meretricious", "minatory", "mordant", "munificent", "nefarious", "noxious", "obtuse", "parsimonious", "pendulous", "pernicious", "pervasive", "petulant", "platitudinous", "precipitate", "propitious", "puckish", "querulous", "quiescent", "rebarbative", "recalcitant", "redolent", "rhadamanthine", "risible", "ruminative", "sagacious", "salubrious", "sartorial", "sclerotic", "serpentine", "spasmodic", "strident", "taciturn", "tenacious", "tremulous", "trenchant", "turbulent", "turgid", "ubiquitous", "uxorious", "verdant", "voluble", "voracious", "wheedling", "withering", "zealous"];
var nouns = ["ninja", "chair", "pancake", "statue", "unicorn", "rainbows", "laser", "senor", "bunny", "captain", "nibblets", "cupcake", "carrot", "gnomes", "glitter", "potato", "salad", "toejam", "curtains", "beets", "toilet", "exorcism", "stick figures", "mermaid eggs", "sea barnacles", "dragons", "jellybeans", "snakes", "dolls", "bushes", "cookies", "apples", "ice cream", "ukulele", "kazoo", "banjo", "opera singer", "circus", "trampoline", "carousel", "carnival", "locomotive", "hot air balloon", "praying mantis", "animator", "artisan", "artist", "colorist", "inker", "coppersmith", "director", "designer", "flatter", "stylist", "leadman", "limner", "make-up artist", "model", "musician", "penciller", "producer", "scenographer", "set decorator", "silversmith", "teacher", "auto mechanic", "beader", "bobbin boy", "clerk of the chapel", "filling station attendant", "foreman", "maintenance engineering", "mechanic", "miller", "moldmaker", "panel beater", "patternmaker", "plant operator", "plumber", "sawfiler", "shop foreman", "soaper", "stationary engineer", "wheelwright", "woodworkers"];

$('button1').click();
}

Credit for code & showing exactly what I need… Random Name Generator - JSFiddle - Code Playground

Hey Faelourn… can you show me how you placed this code?