Hello,

on 03/17/2006 11:42 PM Daevid Vincent said the following:
> I need to dynamically update a select box 
> with results from a SQL database using AJAX, 
> but I can't find a single example of how to do this.
> 
> Basically I have a text input field, and a select box. 
> As someone types in the input field, 
> I want the select box to fill in the results of matches.
> 
> I can fill in a <DIV> (as per the ten million examples out there)
> and that's all fine and dandy, but way too simplistic for what I need.

You may want to take a look at this forms generation class that comes
with a plug-in that lets you do precisely what you ask.

The linked select input plug-in lets you switch the group of options of
a select input upon an arbitrary event, which in your case you need to
be when your text input changes its value.

The plug-in can work in two modes: static and dynamic. In the static
mode it loads all the alternative groups of options with the form. This
is not the way you want.

In the dynamic mode it makes an AJAX call that performs some action and
returns the alternative group of options depending on a value passed
from another input to the server.

In both modes it can take the alternative option groups from arrays or
execute some action that retrives the new options. There specialized
variants of the plug-in to take the options from database queries using
different API. Currently supported API are: MySQL, or any other database
supported by the database abstractions Metabase or PEAR::MDB2 .

There is also another plug-in for generic AJAX form submission in case
you need more special effects.

Here are live examples of the static mode:

http://www.phpclasses.org/mirrors.html

http://www.phpclasses.org/browse/view/html/file/9879/name/test_linked_select_page.html


The example scripts for the dynamic mode come with the class:

You may download the class and all plug-ins, examples and documentation
from here:

http://www.phpclasses.org/formsgeneration

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to