Solved

jquery autocomplete extender

Posted on 2016-08-19
7
53 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
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
The viewer will learn how to dynamically set the form action using jQuery.

831 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