I’m fairly new to coding. I created a search box and connected it to a database, using a script that I found online. It works quite well. The search is activated when you press enter.
However I would like to have the additional option that the search will trigger if I press a search button. I dont know the correct syntax for creating to alternative functions that do the same thing.
This is the Java code that I’m currently using:
import {local} from ‘wix-storage’ ;
import wixLocation from ‘wix-location’ ;
$w.onReady( function () {
});
export function searchbox_keyPress(event, $w) {
if (event.key === “Enter” ){
console.log( “Enter was pressed!” )
let word = $w( “#searchbox” ).value;
local.setItem( "searchWord" , word);
wixLocation.to( `/results-1` );
}
Thanks