Hello,
I am making use of jQuery's .autocomplete plugin, and I would appreciate some assistance formating the results that show up in the dropdown menu that populates when text is written into the input field.
In order to get the data to populate the autocomplete, I pull from mySQL using this PHP: -
$sql = ( 'SELECT tag, title, author, content, id FROM labels' );
-
$result = mysql_query( $sql );
-
$Response = array();
-
while( $row = mysql_fetch_object( $result ) ){
-
$Response[] = array(
-
"id" => $row->id,
-
"name" => $row->tag . ": " . $row->title . ": " . $row->content .""
-
);
-
}
-
When a user selects the option from the autocomplete that is best for them, I convert the "name" above into the "id" using this method: -
var AllTagData = <?= json_encode ( $Response ); ?>;
-
var CRs = [];
-
-
for(var i in AllTagData){
-
Tags.push(AllTagData[i].name);
-
}
-
-
function getIdFromTag(_name){
-
for(var i in AllTagData){
-
if(_name == AllTagData[i].name){
-
return AllTagData[i].id;
-
}
-
}
-
}
-
So far, so good. Finally, I use the jQuery autocomplete plugin to output the data for the user: -
$(document).ready(function(){
-
$("#Responses").autocomplete({
-
source: Tags,
-
matchContains: true,
-
autoFill: true,
-
select: function(e, ui){
-
$("#hidden_tags").val( getIdFromTags($("#Responses").val()) );
-
}});
-
});
-
This final portion of the code is where I need help implementing the formatItem, formatMatch, and formatResult options.
From the PHP given above, I output Tags, Title, and Content all in the "name". The way that I would like to format my autocomplete options for the user is - Show Tags & Title
- Hide Content
- Search through Tags, Title, and Content for possible matches
Therefore, even though I want the autocomplete to search through Content, I don't want Content showing up in the populated autocomplete list. I only want the Tags and Title to show.
I've been having a lot of trouble with this and have searched quite extensively to find an answer and would really appreciate any help you can give on how to accomplish this. Please ask any follow up questions if you need further clarification. Thanks!
0 2085 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: c19h28o2 |
last post by:
Hi,
I'm a little stuck with Ajax (really am not getting it at the moment!)
I'm trying to write into a div when something is typed into a box...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
|
by: mikeh3275 |
last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to get anything to happen. Below is the code. Thanks in advance.
jQuery:
jQuery(document).ready(function()
{
jQuery("a").click(function()
{
jQuery("#dialog").dialog({
modal: true,
|
by: souporpower |
last post by:
Hello All
I am trying to activate a link using Jquery. Here is my code;
<html>
<head>
<script type="text/javascript" src="../../resources/js/
jquery-1.2.6.js"</script>
<script language="javascript" type="text/javascript">
|
by: metaphysics |
last post by:
I am using a jQuery script called LocalScroll, and I have a quick problem that needs fixing. The demo for the script is here: jQuery.LocalScroll - Regular Demo, and the documentation is here: Ariel Flesler: jQuery.LocalScroll. The Local Scroll script uses the toScroll and jQuery scripts to function.
I don't really understand what "hash" means, however the author in the documentation specified that if hash is set to true, the hash of the...
|
by: jrod11 |
last post by:
hi,
I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes.
There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)?
Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html
Here is some jquery js that I think...
| |
by: bytesFTW99 |
last post by:
i have this,
$(function() {
$('#input').autocomplete('test.php', {json: true});
});
that bring back values from the database here is my php section
|
by: pradeepjain |
last post by:
http://www.electrictoolbox.com/jquery-count-words-textarea-input/
hi guys i want to build a autocomplete feature in a textarea . so i thought of like when ever the word count increases call the ajax/jquery so as to find the autocomplete from server . i am using the word count feature from above url . how do i pass the present entered word to server for checking .bcos there may be multiple words also .
like
hello BP ..
when BP is typed...
|
by: RichRadio |
last post by:
Hi,
I have the following script within a user control
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
jQuery().ready(function() {
|
by: aucontraire |
last post by:
I'm using a swf as a background for all of the content on a site. Every page has the same background (swf) but with different amount of content. I want to sync the height of the div of the content with the div of the swf so that the swf nicely frames the content.
I have been able to find pieces of this overwhelming puzzle but have been quite unsuccessful at putting them together. I'm a complete novice when it comes to javascript and...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |