View Full Version : Select list add/remove option

07-16-2007, 04:38 AM
I have a working javascript system that does what I want, but it is painfully slow at times, taking several seconds to accomplish each task and it seems that there ought to be a way to increase the speed of this, especially since I and the source I got it from aren't proficient JS coders. (I'm a PHP guy.)

See the working code at: http://www.everyonepoll.com/poll.php (if you view the source of that page you will see all the (ugly) code.) Also, it does have a username/password field, but you don't need that to see the code in action.

Where, if you select an items in the first dropdown box, the code will remove that item from the other 24 select boxes. The problem is there are 119 select options x 25 boxes to update each time which = slow. Too slow for my tastes.

I know I could check when the form is submitted for duplicate entries, but whynot just take care of that client side? I do check server side after submission anyways, to ensure someone doesn't figure out how to submit the form without these checks to get a team double voted. And "if it ain't broke, don't fix it" sure, but the speed is unbearable to me.

The code is there on the site, and not being a javascript guy I only modified the code to go from 10 to 25 and fit my other needs. So, if someone has any cool shortcut tricks to perhaps increase the speed of this, with or without looking at my current code, I will be much obliged. Or a website that already has this done, I have searched endlessly for weeks without finding anything.

A few facts:
* The list is static. That is, the 119 options to select never changes (except maybe once a year). I can generate it dynamically from a MySQL DB, but it's currently static.
* It takes several seconds for the 25x119 selects to even load, which I think should be near zero as well.
* Selecting an item should take 0.00001 to 1/2 second max to update all other items.
* The problem is much worse in IE than Firefox.
* I've run it on several computers many different times and although the times vary, it's typically 1-3 seconds per selection.
* I understand computer speed and memory and other things will come into play, but on my "high speed" computer, I should be able to achieve the above goals.

If you have any questions, please ask. Thank you in advance. I hope I was clear what I wanted and have given anyone enough info to help me.