I am using Wix Store and display my product in a product gallery (#ID: productgallery1)
I am trying to create an additional dropdown box that allows customers to select the product option they would like and just put it on top of the page. It is kinda like auto select the option, so that when the customers select “Size : 2”, all the product option will be set to “Size : 2” automatically, they do not have to select the option one by one. However, I am not able to link the product option ID from the Editor.
I have tried with the following code:
$w.onReady(function () {
// Populate the dropdown with product options
$w(“#myDropdown”).options = [
{ “label”: “Size: 1”, “value”: “Size: 1” },
{ “label”: “Size: 2”, “value”: “Size: 2” },
{ “label”: “Size: 3”, “value”: “Size: 3” },
{ “label”: “Size: 4”, “value”: “Size: 4” },
{ “label”: “Size: 5”, “value”: “Size: 5” }
];
// Event handler for dropdown change
$w("#myDropdown").onChange((event) => {
const selectedOption = event.target.value;
console.log(selectedOption)
//Product options dropdown with ID #productOptions
$w("#productOptions").value = selectedOption;
});
});
The error in the last code " $w(“#productOptions”)", it said this element does not exist in this page.
Much appreciate if anyone know how to solve on this issue, thank you very much.