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.