On Dec 8, 3:05 am, macsig <[EMAIL PROTECTED]> wrote:
> Hello guys,
> I'm trying to implement a variant of the classic autocomplete but I
> can't make it works.
> Basically what I want is to show for each element that matches with
> the written text the element name and a checkbox (having the element
> id as a value).
> For instance, if my table contains:
>
> ID  | NAME
> 1   | Tom
> 2   | Timmy
> 3   | John
> 4   | Nick
> 5   | Theodora
>
> When I digit 'T' on my textfield the div called "friends" should be
> populated with
>
> [] Tom
> [] Timmy
> [] Theodora
>
> Can someone help me out with this? Any help is welcome.
>
> thanks and have a nice day!
>
There are several separate parts of this:
- generating the entries to include the checkboxes
- acting on the result.

The Ajax.Autocompleter in scriptaculous requires you to return an
unordered list for the 'drop-down', and there's nothing to stop you
putting <input> elements inside the <li>'s. If you still want to use
the "pick an entry from the list and it will be as if that had been
typed in the text input box", you can do that - make sure the <input>
elements are inside <span class="informal">, and the Autocompleter
code will ignore them in generating the value to return.

However, I'm guessing that that is not what you want, but rather for
the user to proceed by ticking some of the boxes. In that case, I
don't think Ajax.Autocompleter is going to be much use to you, and you
might just as well use Ajax.Updater and do the rest yourself. You can
possibly copy some code from Ajax.Autocompleter.

The code you want (in very sketchy form) is something like

observe($('textbox'), 'keypress', function() {
  Ajax.Updater('listdiv', ...
     {parameters: { partname: $F('textbox'), ...

});

And then your Ajax backend would match the 'partname', and deliver a
list of

<li><input type="checkbox" ... ></input>Tom</li>

or maybe just lines with <br> between

You'll need more than this - probably want to put a delay on before
sending, so as not to send until the user has stopped typing for a
bit, and to handle ESC and things. You can copy some of these out of
Ajax.Autocomplete.

Colin

> Sig
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to