suggestion text field like -- google suggestion - using AJAX/Jquery -
when enter letter in text filed , if has match in database, should display matched words. when enter text in travelfrom text field like: should records start when enter travelfrom(text field) auto complete , should google suggestion. how in ajax.
now: retrieve travelfrom data database. when entered first letter in travelfrom textfield, should check , equal, display list of matching records.
i have written jquery/ajax code auto complete suggestion text box , pass textfield value ajax java, check condition. please let me know how check condition , send display suggestion box. please me.
function getautosuggestiondata(){ alert("calling ajax method getautosuggestiondata()"); $(document).ready(function(){ $('#t02travelfrom').keyup(function(e){ alert("1"); var t02travelfrom=$("#<portlet:namespace />t02travelfrom").val(); alert("value of t02travelfrom-->"+t02travelfrom); var autodatastring = 'function=getautodatafield'+'&t02travelfrom='+ t02travelfrom; alert("after autodatastring"); alert("value of autodatastring"+autodatastring); if(t02travelfrom!=0) { $.ajax({ url: "${gettraveldataautourl}", data: autodatastring, cache: false, success: function(html) { alert("success"); } }); return false; }else { } }); }); } traveldetails.java
public void getautosuggestiondata(resourcerequest request, resourceresponse response) throws systemexception { system.out.println("********inside getautosuggestiondata()********"); string tfromstatic =request.getparameter("t02travelfromdyn"); int count = emp_travel_detailslocalserviceutil.getemp_travel_detailsscount(); list <emp_travel_details> traveldetaillists = emp_travel_detailslocalserviceutil.getemp_travel_detailss(0, count); string t02travelfrom; for(emp_travel_details travellist:traveldetaillists ){ t02travelfrom=travellist.gett02travelfrom(); if(tfromstatic.equals(t02travelfrom)){ } } }
try this:
$("#value").keypress(function() { var data = $("#value").val() var datastring = 'function=getvalues'+'&data='+data; $.ajax({ url: "<liferay-portlet:resourceurl></liferay-portlet:resourceurl>", data: datastring , cache: false, success: function(html) { if(html!='') { // todo display html result wherever want. (in case, html values come in drop down) alert(html); $('#value').val(""); } } }); return false; }); on success results in form of html. populate these values in drop down.
hope you.
Comments
Post a Comment