Try this.
export function dropdown1_change(event,$w){
$w("#dataset1").setCurrentItemIndex($w("#dropdown1").selectedIndex)
.then(()=>{
wixLocation.to($w("#dataset1").getCurrentItem().doc)
})
And remove your query to the document database
wixData.query("documents")
.find()
.then((results)=>{
//setting the results to the variable declared above
documents = results.items;
//see item below
})
.catch((err)=>{
leterrorMsg=err;
});
You don’t need this since documents doesn’t exist.
This gives an error and the other code might fail.
Also you don’t need the swich function.
So the code should be like this:
import wixLocation from 'wix-location';
import wixData from 'wix-data';
$w.onReady(function(){
})
export function dropdown1_change(event,$w){
$w("#dataset1").setCurrentItemIndex($w("#dropdown1").selectedIndex)
.then(()=>{
wixLocation.to($w("#dataset1").getCurrentItem().doc)
})