Disable the link of one option in dropdown

Hi

I have created two dropdowns. Only one option ‘Delhi’ of the first drop down opens the second dropdown, all other options get redirected to their respective page as per auto generated field.
The problem is that due to a slight change in the code the option ‘Delhi’ is also being redirected. I want to disable the link of option ‘Delhi’.
Can anyone tell me where I am making a mistake in my code or what other code I need to add to it?

import wixLocation from 'wix-location';
import wixData from 'wix-data';

$w.onReady(function () {

    wixData.query("Delhi Locations")
        .limit(100)
        .ascending("title1")
        .distinct("title1")
        .then(r => {
 let options = r.items;
            options = options.map(e => { return { label: e, value: e }; });
            $w("#cityLocationDropdown").options = options;
        });

    $w('#cityLocationDropdown').options;
    $w('#cityLocationDropdown').disable();
    $w('#cityNameDropdown').onChange(() => {

 if ($w('#cityNameDropdown').value === 'Delhi Locations') {
            $w('#cityLocationDropdown').options;
            $w('#cityLocationDropdown').enable();
        } else {
            $w('#cityLocationDropdown').value = '';
            $w('#cityLocationDropdown').disable();      
        }
    });

});

export function cityLocationDropdown_change(event) {

    $w("#dataset4").setCurrentItemIndex(event.target.selectedIndex)

        .then(() => {
            wixLocation.to($w("#dataset4").getCurrentItem().title2);
        });

}

export function cityNameDropdown_change(event) {

    $w("#dataset5").setCurrentItemIndex(event.target.selectedIndex)

        .then(() => {
            wixLocation.to("/online-cake-and-flowers-delivery/" + $w("#dataset5").getCurrentItem().titleSmall);

 let CitTxt = $w("#dataset5").getCurrentItem().titleMain;
            console.log(CitTxt);
            $w("#deliveryCityText").text = CitTxt;

        });

}

Here is my code for reference. Please help.

I would say that in your cityLocationDropdown_change() function, you should just check for options (eg. Delhi) that should not be redirected.

There might be other ways to do this, such as when you are creating the list of dropdown options, you can assign a value which will not redirect.

It is necessary for me to insert 'Delhi in this database field otherwise the subsequent dropdown will not activate and other calculated autogenerated page url fields will also be removed.

export function cityNameDropdown_change(event) {
  $w("#dataset5").setCurrentItemIndex(event.target.selectedIndex)
        .then(() => {
            wixLocation.to($w("#dataset5").getCurrentItem().title2);
        });

Please suggest me in this code, what changes need to be done to disable cell "Delhi’ of autogenerated page url field.

I’m not sure why you query the dataset for the value instead of having the proper option values in the Dropdown , but in any case, the way you have it now, you can get the value and then take the appropriate action. Something like this:

let value = $w("#dataset5").getCurrentItem().title2;
if(value === "Delhi") {
 // do something here for Delhi
else {
 wixLocation.to(value);
}

Also, you should realize that wixLocation.to() needs a proper URL.