jquery autocomplete extender

Posted on 2016-08-19
Last Modified: 2016-09-02
i have  ajquery autocomplete extender , and i need once i seleect a value i need to select max 5 to do this restriction
Question by:pamela rizk
  • 3
  • 3
LVL 42

Expert Comment

by:zephyr_hex (Megan)
ID: 41762953
You can do the restriction in your SQL query.  Use 'TOP 5'.  You will probably want to have some kind of ORDER BY OR WHERE clause criteria so you can properly identify what records are the top 5.

From MyDatabase

Open in new window


Expert Comment

ID: 41763023
Or (Oracle)
Select MyField
FROM MyDatabase
WHERE ....

Open in new window


Author Comment

by:pamela rizk
ID: 41763753
no i don't want that
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

LVL 42

Expert Comment

by:zephyr_hex (Megan)
ID: 41765480
Can you please clarify what you do want?  

You said you want the max 5 results.  That is ALL we know.  I've given a solution that will give you the max 5 results.

Author Comment

by:pamela rizk
ID: 41766357
sure thank you
what i want is that i want when i select a value from autocomplete extender, i need to manage a counter and each time user select a value the counter will be incremented and once it reaches 5 a message will be displayed
LVL 42

Accepted Solution

zephyr_hex (Megan) earned 500 total points
ID: 41767209
To accomplish this, you can use a hidden field that tracks the number of selections, and display a message when it reaches 5.

Here is a Fiddle Demo.

Given the following HTML

<div class="ui-widget">
  <label for="tags">Tags: </label>
  <input id="tags">
<input type="hidden" id="hCount" value="0">
<span id="msg"></span>

Open in new window

The jQuery looks like:

  $(function() {
    var availableTags = [
      source: availableTags,
      select: function(event, ui) {
        var num = parseInt($('#hCount').val());
        $('#hCount').val(num + 1);
        if ((num + 1) === 5) {
          $('#msg').text('You have selected 5');

Open in new window


Author Closing Comment

by:pamela rizk
ID: 41781150
thank you it solved my issue

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now