![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
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
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](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
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
![Avatar of pradyahuja](https://filedb.experts-exchange.com/files/public/2013/11/18/16fd388b-af54-4683-8637-b552e250f674.png)
please explain more
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
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 ...
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 ...
![Avatar of pradyahuja](https://filedb.experts-exchange.com/files/public/2013/11/18/16fd388b-af54-4683-8637-b552e250f674.png)
you already have a page to display search results?
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
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?
I'm wrong?
![Avatar of pradyahuja](https://filedb.experts-exchange.com/files/public/2013/11/18/16fd388b-af54-4683-8637-b552e250f674.png)
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
table is created when loading the page.
you will have to refresh the page with querystring and then search based on the query string
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Ok and how i get the value selected in the autocomplete to add in the querystring?
![Avatar of pradyahuja](https://filedb.experts-exchange.com/files/public/2013/11/18/16fd388b-af54-4683-8637-b552e250f674.png)
change following code
$("#example").autocomplete ('autocomp lete.asp',
{ minChars:2,
cacheLength:10,
//formatResult: function(data, value) {
//return value.split(".")[0];
//}
});
to attached code
$("#example").autocomplete
{ 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
});
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Great is working but it gives me Teodor Birca.394 how i could part the string to get only the id in the query?
![Avatar of pradyahuja](https://filedb.experts-exchange.com/files/public/2013/11/18/16fd388b-af54-4683-8637-b552e250f674.png)
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]
});
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
still return me both name and id
![Avatar of pradyahuja](https://filedb.experts-exchange.com/files/public/2013/11/18/16fd388b-af54-4683-8637-b552e250f674.png)
$("#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]
});
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
data.split is not a function
[Break on this error] location.href="show_bookin gs.asp?q=" + data.split(".")[0]
[Break on this error] location.href="show_bookin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
![Avatar of Softacid](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Thank you very much is working now
ASKER
http://view.jquery.com/trunk/plugins/autocomplete/demo/