On Aug 27, 9:08 pm, Eric <
LeFauv...@gmail.com> wrote:
> On Aug 27, 10:37 am, RobG <
rg...@iinet.net.au> wrote:
>
> > On Aug 27, 12:14 am, Eric <
LeFauv...@gmail.com> wrote:
> > > However, while it is a little overkill to just clear the list, does
> > > anyone known a solution as fast as this "non-standard" one when we
> > > want to fill a select with many hundreds of options?
>
> > Yes, the one involving length that has been posted twice and is W3C
> > standards compliant:
>
> My question was perhaps a little unclear and I apologize for that.
>
> I did notice that setting the length to 0 was a fast way to clear the
> options list.
> And I also agree it is a cleaner way than emptying the
> select.innerHTML.
>
> My question was about quickly fill the options list with many hundreds
> of entries.
Ah, I thought you were still asking about removing them.
> This is very fast using innerHTML to replace the select tag with the
> result of an ajax call, but my question was:
>
> Is it a way to fill quickly the options list of a select control other
> than using innerHTML?
DOM operations are pretty quick on some browsers, but innerHTML is
likely fastest overall.
There are various issues regarding formatting the data you send in the
AJAX response, but likely you are already generating HTML on the
server in response to the query so it is probably easier to stick with
that - and if you are completely replacing the innerHTML you don't
have to worry about removing the existing options.
--
Rob