Alternative for Select tag with thousands of options?
Discuss Alternative for Select tag with thousands of options? in the JavaScript Development forum on Dev Shed. Alternative for Select tag with thousands of options? JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
Posts: 2,353
Time spent in forums: 2 Days 12 h 39 m 5 sec
Reputation Power: 116
Alternative for Select tag with thousands of options?
I have a select tag that is dynamically created for users that log into my web app. Some users can have 2000-8000 options in the select tag, and there can be multiple select tags on the page. Each select tag can add almost a meg of information to the page.
The problem I have been running into is not the file size, but the time it takes the browser to render once it has gotten the information. Plus, I had it so users can dynamically add more "funds" (in this case) by clicking a button and it would clone the table the select is in and make a new one for them to choose another fund out of, but when the user has that many funds, it takes 5 seconds or more on my pc (which is pretty fast) to render the cloned node, which is clearly unacceptable.
Has anyone else run into this problem and come up with an alternative?
Posts: 2,056
Time spent in forums: 2 Weeks 3 Days 7 h 58 m 28 sec
Reputation Power: 1319
Man, thats a lot of data for javascript to be handling....
So there are multiple select tags, but each select statement is a single select? if that so, i have an easy one for you. Don't loop thru your data to select the right record, just add it to the end as a new option. yes, you will duplicate data on the dropdown, but you should save a TON of processing time and also it won't matter which value they select, it will work with either one.
__________________
Three gigs for the secretaries fair
Seven gigs for the system source
Nine gigs for the coders in smoky lairs
One disk to rule them all, one disk to bind them
One disk to hold the files, and in the darkness grind'em
---------------------------------------------------
It is by caffeine alone that I set my mind in motion.
It is by the beans of Java, that my thoughts acquire speed.
The hand acquire shakes; the shakes become a warning.
It is by caffeine alone that I set my mind in motion.
Posts: 2,353
Time spent in forums: 2 Days 12 h 39 m 5 sec
Reputation Power: 116
I'm not sure I explained myself well. The select tags are dynamically created the first time server side, not by the browser. Bad terminology on my part. The browser receives straight, properly formed html initially.
It takes the browser a long time to render the page when it loads PLUS it takes a long time to duplicate the select tag dynamically (in the browser this time using javascript).
I have attached a sample file for anyone that wishes to see an example.
Posts: 1,442
Time spent in forums: 1 Week 1 Day 1 h 37 m 42 sec
Reputation Power: 28
To find the best solution I think it would pay to look at what the user wants to do on the page and what sort of information they are likely to know etc.
You're demo does demonstrate that it takes a bit to load, but perhaps the best solution is to redesign the interface so the user doesn't have to look at 2000-8000 options.
Honestly, with that many options, if the user doesn't know before he gets to the select box what he wants then the select box isn't going to help him anyway.
Why are you providing them with a select box with so many options? Is it an attempt to avoid typing errors or something? If so just validating their entry is probably a superior method. You could even use an AJAX auto complete script if you felt the need.
__________________
Like the answers I give? Why not ask me directly at my forum. I'm always glad to help.