Link to home
Start Free TrialLog in
Avatar of Softacid
Softacid

asked on

Jquery autocomplete on select post the value ...

Hello,

just installed in one of my ASP script the jquery autocomplete.
My question now is how to make it that in the mment when i select from autocomplete a value to be posted the id of the value to the page in order to filter the records based on the Name i chose in the autocomplete?

Thank you
Avatar of Softacid
Softacid

ASKER

For the moment i have a page that gather the records from a db and i use this :



$("#example").autocomplete('autocomplete.asp',
{ minChars:2,  
cacheLength:10,

		
});

 Quick Search by Client Name: <input type="text" name="q" id="example" />

and autocomplete.asp is:

nome = Request("q")
SQL = "SELECT  id,c_full_name FROM bookings WHERE c_full_name like '"&nome&"%' "
set Rs = conn.Execute(SQL)
WHILE NOT Rs.EOF
Response.Write Rs("c_full_name")&"."&Rs("id") & vbCrLf
Rs.Movenext
Wend

Open in new window

please explain more
Take a look at :
http://tourscript.com/hrslast/secure/admin/show_bookings.asp
admin/pass
when i use the autocomplete textbox and select a record i will like to see on the page only the booking with id of that record.
Like a quick search by client name.
And then to add a button like  show all records after ...
you already have a page to display search results?
i just tought if already i have this page ready show_bookings.asp in the moment that a user select a name in autocomplete then i will pass via jquery the value to the actual SQL query and show the record just for that id ..
I'm wrong?
you r not loading the table using jquery.
table is created when loading the page.
you will have to refresh the page with querystring and then search based on the query string
Ok and how i get the value selected in the autocomplete to add in the querystring?
change following code
$("#example").autocomplete('autocomplete.asp',
{ minChars:2,  
cacheLength:10,
//formatResult: function(data, value) {
                  //return value.split(".")[0];
            //}



            
});


to attached code
$("#example").autocomplete('autocomplete.asp',
{ minChars:2,  
cacheLength:10,
//formatResult: function(data, value) {
			//return value.split(".")[0];
		//}



		
});

$('input#example').result(function(event, data, formatted) {
location.href="show_bookings.asp?q=" + data
});

Open in new window

Great is working but it gives me Teodor Birca.394 how i could part the string to get only the id in the query?

can u try this code
$("#example").autocomplete('autocomplete.asp',
{ minChars:2,  
cacheLength:10,
//formatResult: function(data, value) {
			//return value.split(".")[0];
		//}



		
});

$('input#example').result(function(event, data, formatted) {
location.href="show_bookings.asp?q=" + data[0]
});

Open in new window

still return me both name and id

$("#example").autocomplete('autocomplete.asp',
{ minChars:2,  
cacheLength:10,
//formatResult: function(data, value) {
			//return value.split(".")[0];
		//}



		
});

$('input#example').result(function(event, data, formatted) {
location.href="show_bookings.asp?q=" + data.split(".")[0]
});

Open in new window

data.split is not a function
[Break on this error] location.href="show_bookings.asp?q=" + data.split(".")[0]

ASKER CERTIFIED SOLUTION
Avatar of pradyahuja
pradyahuja
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much is working now