better way to do this? ('already declared in upper scope')

Hi and Happy New Year to all,

Goal is: Upon dropdown3’s menu change, check if dropdown4 is enabled ( through an irrelevant condition running somewhere else, no problem) . If this is so, wait for dropdown4’s change and once this happens do stuff).

The code below works and I’m fine but I get a yellow notice that ‘event’ is already declared. How could I do this better?

$w("#dropdown3").onChange(event => {
 if ($w("#dropdown4").enabled) {
            console.log("Dropdown 4 is enabled!")
            $w("#dropdown4").onChange(event => {
                   let dropdownvalue = $w('#dropdown4').value;
                       console.log("Dropdown 4 value is:", dropdownvalue)  ;       
                       $w('#dataset1').setFilter(wixData.filter().eq("typeId", dropdownvalue))
                              .then( ( ) => {
                              $w("#dropdown1").disable();
                              $w("#dropdown2").disable();
                              $w("#dropdown3").disable();
                              $w("#dropdown4").disable();
else {} ....

Also, how can I concatenate the repetetive commands to disable each and every dropdown, one by one, in just one line?

Thanks.

To get rid off the yellow notice, you could try to change the second → “event” into —> “event2” or something like that. Perhaps this is your solution.
(although i never have seen such an change in a change event)

And the second: Use a simple “for-loop”…

for (var i = 0; i < number of dropdowns here; i++) {
    $w("#dropdown"+i).disable()
}
  1. in the 2nd on change use event1 instead of event (if you don’t like the yellow mark, which is by the way a warning, not an error. It 's saying: be aware, you’re overriding the event ). In your case since you don’t use the event you can replace it by ()

  2. You can try:

$w("#dropdown1, #dorpdown2").disable();