Tuning question: JavaScript to generate options inside select
-
Hello togetherm I have a self written AJAX-Combobox and I have a tuning problem inside javascript. I get many records from server and will fill a client side combobox (select element) with all records like this:
for (var i = 0; i < length; i++) { oSel.options[i] = new Option (arrT[i], arrV[i], false, false); }
This takes 30 seconds for 3600 array elements (-> 3600 options will be created). Have anybody an idea, how I can create the options very very faster? Thank you very much Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_) -
Hello togetherm I have a self written AJAX-Combobox and I have a tuning problem inside javascript. I get many records from server and will fill a client side combobox (select element) with all records like this:
for (var i = 0; i < length; i++) { oSel.options[i] = new Option (arrT[i], arrV[i], false, false); }
This takes 30 seconds for 3600 array elements (-> 3600 options will be created). Have anybody an idea, how I can create the options very very faster? Thank you very much Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)Just an idea. (not so sure whether it will work with your self-written Ajax-combobox). What about loading the data on demand? Like Microsoft Live Search result or dzone search result. In your case, it will be in your combobox instead of a page. You have 3600 records in the database, right? firstly, you can load a few records (50 or 100 records) and add them to your combobox. then, when the user scroll down then you can load the more records on demand...
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Just an idea. (not so sure whether it will work with your self-written Ajax-combobox). What about loading the data on demand? Like Microsoft Live Search result or dzone search result. In your case, it will be in your combobox instead of a page. You have 3600 records in the database, right? firstly, you can load a few records (50 or 100 records) and add them to your combobox. then, when the user scroll down then you can load the more records on demand...
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Yes. But (sorry for my stupid answer) I have no time to implement it. Have only time to make the line inside the loop faster. Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_) -
Yes. But (sorry for my stupid answer) I have no time to implement it. Have only time to make the line inside the loop faster. Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)Stephan Pilz wrote:
Have only time to make the line inside the loop faster
Okay. All the best!
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Hello togetherm I have a self written AJAX-Combobox and I have a tuning problem inside javascript. I get many records from server and will fill a client side combobox (select element) with all records like this:
for (var i = 0; i < length; i++) { oSel.options[i] = new Option (arrT[i], arrV[i], false, false); }
This takes 30 seconds for 3600 array elements (-> 3600 options will be created). Have anybody an idea, how I can create the options very very faster? Thank you very much Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)As Michael suggested, your best bet is to find a way of putting fewer items in the list. Not only will that speed up the routine, but you may actually find that your end-user is able to find items in the list more quickly as well... Otherwise, try building the HTML for the options in-memory and blasting it all out at once by assigning it to
oSel.innerHTML
. Might be a little faster, depending on the browser in use. -
As Michael suggested, your best bet is to find a way of putting fewer items in the list. Not only will that speed up the routine, but you may actually find that your end-user is able to find items in the list more quickly as well... Otherwise, try building the HTML for the options in-memory and blasting it all out at once by assigning it to
oSel.innerHTML
. Might be a little faster, depending on the browser in use.Shog9 wrote:
try building the HTML for the options in-memory and blasting it all out at once by assigning it to oSel.innerHTML. Might be a little faster, depending on the browser in use
Yeah. I think this is good idea too..
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)