Ok, did not want to be rude.
Just wanted to hear from you that you have tried really tried it on your own.
I am not frustrated
, just wanted to see your own actions, wanted to see that you are willing to learn.
It seems you do!
Normaly you should see the following message on your CONSOLE…
“Dropdown-Value and INDEX has been changed!”
…and …
“Index + selectedIndex of your Dropdown”
…when you change dropdown-value/selection.
And now just for you, i will demonstrate you what i wanted to see from you…
- Generating a TESTING-PAGE…(including a DropDown)… -->EXPAND-PIC!
This will be our little and very simple testing-page.
What you can see on the pic is the PREVIEW-MODE of your Wix-Editor.
On the very
BOTTOM of the Preview-Mode-Screen , you can see the
CONSOLE !
The console is empty at the beginning, because nothing happens!
- Now we are going to change some VALUES inside the DropDown…
We choose —> BLACK

…and take a look onto → CONSOLE! —> RESULT ???
What you can see on the CONSOLE ?
Now you got a message and a RESULT.
-----> RESULT = 1 <----- What does this mean ?
1 = INDEX of the DROPDOWN.
But why —> 1 ?
Normaly BLACK is the → second ← value inside our DropDown.
Because? Because in programming-language everything starts to count from ??? → EXACTLY → from —> 0.
Ok! Till here everything should be clear now!
OUR CODE IS WORKING ALREADY!
So what do you know now?
And what was your aim one more time?
And how to combine the new knowledge with your wished feature ?
Make some thoughts about that.
By the way, the following code was used in the shown example…
$w.onReady(()=>{
$w('#dropdown1').onChange(()=>{
console.log("Dropdown-Value and INDEX has been changed!");
console.log("Index: ", $w('#dropdown1').selectedIndex);
});
});
And some more infos for you.
Here…
xxx | My Site 5 (russian-dima.editorx.io)
…you can see the live-example. By using F12 on your keyboard, you also can open the LIVE-SITE-CONSOLE in your BROWSER (google-chrome or microsoft-edge for example)
You click onto F12-keyboard-button and the console of your browser will open (maybe you still will have to navigate to CONSOLE) → click on → CONSOLE.
Now do some changes inside your dropdown and see what happens in the CONSOLE of your Browser.
BTW: Of course you have first to publish your website, before you can see your LIVE-WEBSITE and the related console-logs on the browsers console.
Furthermore, i do not understand why you got no errors on your screen, when testing my code, because my code have had syntax-errors and also the ID of the dropdown was not really correct.
- ID-Error ----> $w(‘#dropddown1’).onChange(()=>{
- Syntax-Error: → console.log("Index: ", $w(‘#dropddown1’).selectedIndex);
This 2 errors were inside my first posted code.
Later the syntax-error was corrected in the second posted code, but still the element-ID was not really correct.
But ok, i don’t want to overload you to much, let’s go back to your own ERRORS.
You are using this one…
export function button22_click(event) {
if (($w("#dropdown1").value === "option1").wixWindow.openLightbox("lightbox1"));
if (($w("#dropdown1").value === "option2").wixWindow.openLightbox("lightbox2"));
if (($w("#dropdown1").value === "option3").wixWindow.openLightbox("lightbox3"));
}
My comment on this was…
- DO NOT USE EXPORT-FUNCTIONS.
Yes it is possible to use them, but not recommende.
There is a big difference between my used coding-style and yours.
You always have to connect your buttons additionaly through the PROPERTY-PANEL.
Using my code this action is not needed to be done.
It often happens that someone opens a post, and describes his issue as following…
“Hello i have a problem with my buttons!”
Yesterday everything worked well, but i did something and nothing works anymore and i don’t know what happened".
And all what happened was just a broken connection between PROPERTY-PANEL and your/his CODE!
This is just one of many reasons WHYYOU SHOULD NOT USE EXPORT-FUNCTIONS.
And i also wrote something about generating the code a more direct style…
…and you got even a code-example… see pic…
This was the code-line you have had to add to your already existing code, which would look something like…
import wixWindow from 'wix-window';
$w.onReady(()=>{
$w('#dropdown1').onChange(()=>{
console.log("Dropdown-Value and INDEX has been changed!");
console.log("Index: ", $w('#dropdown1').selectedIndex);
wixWindow.openLightbox("lightbox"+$w('#dropdown1').selectedIndex);
});
});
As you can see on the very top we have also imported the right API
import wixWindow from 'wix-window';
Now inspect the following code-line, what does this code-line do ???
wixWindow.openLightbox("lightbox"+$w('#dropdown1').selectedIndex);
END-RESULT: (This pice of code should normaly be the solution for your question/issue).
A DIRECT DROPBOX-SWITCH, OPENING CORRESPONDING LIGHBOXES ON VALUE-CHANGE.
import wixWindow from 'wix-window';
$w.onReady(()=>{
$w('#dropdown1').onChange(()=>{
console.log("Dropdown-Value and INDEX has been changed!");
console.log("Index: ", $w('#dropdown1').selectedIndex);
wixWindow.openLightbox("lightbox"+$w('#dropdown1').selectedIndex);
});
});
Or even a better version…(without console-logs)…
import wixWindow from 'wix-window';
$w.onReady(()=>{
$w('#dropdown1').onChange(()=>{
let selIndex = $w('#dropdown1').selectedIndex;
wixWindow.openLightbox("lightbox"+selIndex);
});
});
Now jump one more time onto the example-page and do some testings.
QUESTION:
Which elements are needed to reconstruct this example, to get it to work using the shown code?
ANSWER:
- 1x DropDown
- 1x or more LIGHTBOXES

- CODE by Velo-Ninja

EDIT: CONSOLE-LOG inside of Microsoft-EDGE-BROWSER…
And indeed!!! → There is no “lightbox0” <— because i never created it in my example

.
Have fun.