mardi 28 avril 2020

Clickable links in autocomplete search box

I have created a clickable search bar but am having trouble in redirecting the web browser once the user clicks the link.

    <script type="text/javascript">
var source = [ {value: "www.google.com", label: "This is a test"}];

$(document).ready(function() {
    $("input#autocomplete").autocomplete({
        source: source,
        select: function( event, ui ) { 
            window.open.href = ui.item.value;
        }
    });
});

</script>

is the select function implemented correctly? My understanding of this is that when the user clicks the suggested drop down link the select function is called and the "Window.open.href = ui.item.value" is used to redirect the browser.. but so far the browser just fills the search input. Any help would be appreciated.




Aucun commentaire:

Enregistrer un commentaire