Solved

jquery autocomplete extender

Posted on 2016-08-19
7
56 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 43

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 43

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 43

Accepted Solution

by:
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">
</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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
The viewer will learn how to dynamically set the form action using jQuery.

623 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