Where I should put it in ?
import wixData from 'wix-data';
import wixLocation from'wix-location';
let myValue
$w.onReady(()=>{
$w('#input1').onChange(()=>{console.log("My value setted!")
myValue = Number($w('#input1')).value;
});
$w('#button1').onClick(()=>{console.log("Button-1 clicked!")
searchIndex(myValue)
wixLocation.to("https://wix.com");
});
});
function searchIndex(VALUE){console.log("Searchfunction started.")// VALUE = value from your inputfield.
let DATAFIELD = "index" //<put in here the ID of your DATAFIELD (INDEX)
wixData.query("SitesID") //<---- put in here the ID of your new DB !
.eq(DATAFIELD, VALUE) //<---- This one is new and will do the filtering !
.find()
.then((results) => {console.log(results)
let items = results.items
if(items.length > 0) {
let myURL = results.items[0].url; console.log(myURL)
wixLocation.to(`${myURL}`);
} else {
// handle case where no matching items found
}
})
}