Input Value Redirect

@russian-dima

With this code.

When I choose any number. It redirect me to the same URL.

For Example : 1001 redirect to https://wix.com/1001 ,
1935 redirect to https://wix.com.1001.

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
 }
 })
 }