Suggested changes to the script

Brian Brewder's Avatar

Brian Brewder

07 Nov, 2010 07:42 AM

I love the script, but I made a couple of minor modifications to it to meet my needs. In particular, I wanted to be able to initially populate the field by setting the value of the textbox and getting the value on the server using the name that I gave to the textbox.

If you are interested in using these changes, I've attached the file (hopefully :). Specifically the changes are to the following lines (the comments are not in the attached file).

These 3 changes allow me to use the original value of the Textbox to initialize the tags.

Line ~28...

emptyText: "No Results Found",
//preFill: {}, // remove this so we can tell if it was set or not.
limitText: "No More Selections Are Allowed",

Line 73...

var input = $(this);
var origVal = input.val(); // Need to grab the original value before changing the value below.
input.attr("autocomplete", "off").addClass("as-input").attr("id", x_id).val(opts.startText);

Line ~86...

var prefill_value = "";
if (!opts.preFill) opts.preFill = origVal; // if preFill wasn't set, use the original value.
if (typeof opts.preFill == "string") {

This change allows me to use the name that I gave to the Textbox to fetch the values on the server.

var results_ul = $('<ul class="as-list"></ul>');
// Name the hidden input the same as the original textbox.
var values_input = $('<input type="hidden" class="as-values" name="' + input.attr('name') + '" id="as-values-' + x + '" />');
input.removeAttr('name'); // remove the name attribute from the original textbox.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • jquery.autoSuggest.js 19.3 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac