Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jquery autocomplete extender

Posted on 2016-08-19
7
Medium Priority
?
57 Views
Last Modified: 2016-09-02
i have  ajquery autocomplete extender , and i need once i seleect a value i need to select max 5 values.how to do this restriction
0
Comment
Question by:pamela rizk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 44

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.

SELECT TOP 5 MyField
From MyDatabase
WHERE ...
ORDER BY ...

Open in new window

0
 
LVL 1

Expert Comment

by:brianmfalls
ID: 41763023
Or (Oracle)
Select MyField
FROM MyDatabase
WHERE ....
AND ROWNUM <= 5
ORDER BY  ...

Open in new window

0
 

Author Comment

by:pamela rizk
ID: 41763753
no i don't want that
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 44

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.
0
 

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
0
 
LVL 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 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">
</div>
<input type="hidden" id="hCount" value="0">
<span id="msg"></span>

Open in new window


The jQuery looks like:

  $(function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
    $("#tags").autocomplete({
      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

0
 

Author Closing Comment

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

715 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