• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 969
  • Last Modified:

Scriptaculous Autocomplete trigger search without typing

Hi I am using Scriptaculous' Autocompleter. I want the autocomplete text box to also act like a drop down. So right now when i type something it displays a list of matches (suggestions) and i can cursor down to select whatever i see fit. I want to be able to click on the text box and display the FULL list of results without having to type in some text first.

Anyone know how?
  • 2
1 Solution
You just need to create a function that triggers your element onFocus of the text input. Then all you have to do is pre-populate your autocomplete element with everything you want the user to see if it's blank.
TonyTone1Author Commented:
Yes, I understand  the theory, I was looking as to something more practicle, like a code sample.
Without seeing how your autocompleter updates, the most basic example I can give you is:

////// javascript //////
function updateCompleter(){
      var inputValue = encodeURIComponent($('box').value);
      new Ajax.Updater('autocompleter','ac.php',{parameters:'box='+inputValue, onComplete:function(){Element.show('autocompleter');}});

////// html //////
<input type="text" id="box" name="box" onfocus="updateCompleter();" /><input type="submit" value="go" />
<div id="autocompleter"></div>

you would just need to make sure that your autocompleter page allows for a blank post value, and displays all items.

Personally, I think there are better ways to do "auto-complete" with scriptaculous than using Ajax.Autocompleter. Seems like there's a lot of issues with functionality.
Forced accept.

EE Admin

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now