javascript - Autocomplete Jquery, and show results -
how can create search, autocomplete json file, , after submit value show resultes in new page data of value selected
here html file:
<form action="/dosomething"> <input/> <button type="submit"></button> </form>
my json file :
[ { "title": "stackoverflowsite1", "link": "www.stackoverflow.com" }, { "title": "stackoverflowsite2", "link": "www.stackoverflow2.com" }, { "title": "stackoverflowsite3", "link": "www.stackoverflow3.com" } ]
how can parse data autocomplete , showing results after that's ? please, , thank !
form submit whatever action have directed to. call autocomplete on field want fill, define data, , should off races.
<form action="/dosomething"> <input id="fillme" /> <button type="submit"></button> </form> var sourcejson = [ { "title": "stackoverflowsite1", "link": "www.stackoverflow.com" }, { "title": "stackoverflowsite2", "link": "www.stackoverflow2.com" }, { "title": "stackoverflowsite3", "link": "www.stackoverflow3.com" } ] $( "#fillme" ).autocomplete({ minlength: 0, source: sourcejson, focus: function( event, ui ) { $( "#fillme" ).val( ui.item.title ); return false; }, select: function( event, ui ) { $( "#fillme" ).val( ui.item.title ); return false; } }).autocomplete( "instance" )._renderitem = function( ul, item ) { return $( "<li>" ) .append( "<a>" + item.title+ "</a>" ) .appendto( ul ); };
Comments
Post a Comment