TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sindhu Yadav
NA
11
7.1k
search box functionality in ajax jquery
Jan 2 2015 2:48 AM
Hi,
If i search a letter in 'Search Box' for example 'a', 'a' related wordings should come in drop down with hyperlink. Data should fetch from database. I have created database for this search box and stored all 'a' related wording in the database.
Now its displaying the 'a' related Items in the drop down list without any link. Now I am able to get only the first element from drop down list. But i would like to get and access selected item
(using mouse or keyboard)
from the list instead of the first item. Please suggest an answer.
The dropdown is from jQuery UI.
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js
Here is the part of the jquery code where I am accessing the first element from the list using data.d[0].
Code:
<script type="text/javascript">
$(document).ready(function () {
SearchText();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../WFMTransaction/newf.aspx/GetAutoCompleteData",
data: "{'form_name':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function (data) {
response(data.d)
document.getElementById("Button1").href = data.d[0];
document.getElementById("Button1").text = data.d[0];
},
error: function (result) {
alert("Error");
}
});
},
});
}
</script>
Reply
Answers (
2
)
Web site visitor counter using jquery or javascript
Search Box Functionality in Ajax Jquery