Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use jquery autosuggest to redirect to another url?
    primarykey
    data
    text
    <p>So I've been scouring the internet for a solution that I thought was going to be common and easy, but it seems that all the links I've browsed upon are either more than what I need or they just glaze over the parts I need and want to understand.</p> <p>I'm developing a site where I would like to have a field where users can type in a state, it will autosuggest possible states and when a user selects a state it will redirect the page to another url. So: if they select "Alaska, AK" they get directed to "http://.../states/alaska"</p> <p>From all that I've searched through, the <a href="http://jqueryui.com/demos/autocomplete/#remote" rel="nofollow">jquery UI autosuggest remote source</a>, seems to be the closest to what I need. I liked that I wasn't needing to go through a database, the values are in the "search.php" file.</p> <p>In the search.php file the values are inserted as: </p> <pre><code>$q = strtolower($_GET["term"]); if (!$q) return; $items = array( "Great Bittern"=&gt;"Botaurus stellaris", "Little Grebe"=&gt;"Tachybaptus ruficollis", "Black-necked Grebe"=&gt;"Podiceps nigricollis", "Little Bittern"=&gt;"Ixobrychus minutus", ... </code></pre> <p>I've tested that I can change the values here to:</p> <pre><code>$q = strtolower($_GET["term"]); if (!$q) return; $items = array( "Alabama, AL"=&gt;"http://.../states/alabama", "Alaksa, AK"=&gt;"http://.../states/alaska", "Arizona, AZ"=&gt;"http://.../states/arizona", ... </code></pre> <p>In the HTML the code is:</p> <pre><code>$(function() { function log( message ) { $( "&lt;div/&gt;" ).text( message ).prependTo( "#log" ); $( "#log" ).scrollTop( 0 ); } $( "#birds" ).autocomplete({ source: "search.php", minLength: 2, select: function( event, ui ) { log( ui.item ? "Selected: " + ui.item.value + " aka " + ui.item.id : "Nothing selected, input was " + this.value ); } }); }); </code></pre> <p>I don't need it to show a log, how do I reformat this to get the page to redirect when selected or when the user hits the submit button?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload