top of page

Voting page

Voting is not possible anymore as of 01-05-2023 09:00 CEST.

bottom of page
import wixData from 'wix-data'; $w.onReady(function () { // Get the first five options from the database collection wixData.query("Options") .limit(5) .find() .then((results) => { let options = results.items; // Loop through the options and add them to the page options.forEach((option) => { let title = option.Title; let imageUrl = option.Image ? option.Image[0].url : ''; let optionContainer = $w('#optionContainer'); let newOption = optionContainer.children[0].clone(); newOption.id = `option_${option._id}`; newOption.children[0].src = imageUrl; newOption.children[1].text = title; // Set up the click handler for the option newOption.children[2].onClick(() => { // Increment the vote count for the option wixData.update("Options", option._id, { "Votes": option.Votes + 1 }) .then(() => { // Reload the page to update the vote count location.reload(); }); }); optionContainer.insert(0, newOption); }); }); });