Re: PHP, SQL, AJAX, JS and populating a SelectBox?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daevid Vincent wrote:
> 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.

The best way to do this is indeed to put the entire select in a div, and
to replace the innerHTML of that div with the html for the select.
Always do as much processing as possible on the server side, or your
application will become interminably slow both to load and to run.

In my testing, I've found that the latency over high speed internet of
passing the entire select is exactly the same as it is from my local
machine.  When I used to pass an array of data and repopulate using
javascript DOM, it was slow as molasses, and I would occasionally have
weird timeouts.

Don't try to be smart when you can be simple :)

Greg

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux