Input Value Redirect

I think you did not have read my last post very carefully!
You still have this WRONG part here…

$w('#button1').onClick(()=>{
	console.log("Button-1 clicked!")searchIndex(myValue)      	
	wixLocation.to("https://wix.com"); 
});

What happens here???

-You click on button1.
-you make a console.log to tell that button-1 is cklicked to see it later in console.
-you start the function → “searchIndex()” —> with tehe value → “myValue”
-but you also start immediately the redirection ???

Your redirection should not start before you got the RESULT out of DB for URL.

Try this one…

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

//------User-Interface---------
var DATABASE = "SitesID"  //<---- put in here the ID of your new DB !
var DATAFIELD = "index"   //<--put in here the ID of your DATAFIELD (INDEX)
//------User-Interface---------

var myValue  

$w.onReady(()=>{ 
   $w('#input1').onChange(()=>{
      myValue = Number($w('#input1')).value;
      console.log("My value "+ myValue +" setted!") 
   });
 
   $w('#button1').onClick(()=>{console.log("Button-1 clicked!") 
      searchIndex(myValue) 
   }); 
});

function searchIndex(VALUE){console.log("Searchfunction started.")
   wixData.query(DATABASE) 
  .eq(DATAFIELD, VALUE) 
  .find()
  .then((results) => {
     let items = results.items; console.log(items)
     if(items.length > 0) {console.log("Item found! Redirection starts in 3-secs.")
        let myURL = results.items[0].url; console.log("Item-URL: ", myURL)
        setTimeout(()=>{wixLocation.to(myURL);},3000);
     }else {console.log("No matching data found in DB."}
   })
}