How to pre-populate selections?

Alec's Avatar


18 Oct, 2012 02:31 PM

Last question, how do I go about pre-populate data? :)

Thanks a lot!

  1. 1 Posted by Jon on 18 Oct, 2012 03:24 PM

    Jon's Avatar

    You can use the prefill parameter:

    preFill: [ { value: "1", name: "Mark" } ]

    Or you can take a look to this thread if you want to add the data dynamically.

  2. 2 Posted by Alec on 19 Oct, 2012 02:46 PM

    Alec's Avatar

    Thanks Jon. That works.

    Now, the last bit is to maintain my current functionality, which there is a drop down box, which users select an option and it gets added into the textbox. Now that i;ve got the textbox to work with auto suggest plugin, I also want to keep this dropdown working, do you know how I could get this work with the plugin?

    This is my existing script:

    function ddlSuburbs_onClick() {

            var listBox = document.getElementById('ddlSuburbs');
            var textbox = document.getElementById('txbSuburb');
            var totalContent = textbox.value.split("; ");
            if (textbox.value == '') {
                textbox.value = listBox.options[listBox.selectedIndex].text;
            else {
                for (var i = 0; i < totalContent.length; i++) {
                    if (totalContent[i] == listBox.options[listBox.selectedIndex].text) {
                        return false;
                textbox.value += "; " + listBox.options[listBox.selectedIndex].text;
            return false;
  3. 3 Posted by Jon on 06 Nov, 2012 07:48 AM

    Jon's Avatar

    Use the file attached.


    var data = [ { value: '1', name: 'Jon' } ];
    $("#autosuggest").trigger("add_item_extra", data);
  4. 4 Posted by Wasim on 23 Feb, 2013 02:11 PM

    Wasim's Avatar

    This is great, but I was wondering if there was a way to preFill the selection after instantiation, like with a method? Please let me know.

Reply to this discussion

Internal reply

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

Attaching KB article:


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