Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Adding options to a drop-down list in one go with JavaScript

Posted on 2007-07-31
6
Medium Priority
?
192 Views
Last Modified: 2013-11-27
Is there a way  in JaveScript that you can add an array of options to a drop-down list in one go rather than iterating through the array and adding each option individually?
0
Comment
Question by:Silas2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19599899
without using any loop (for,foreach,...) you cannot do that
0
 
LVL 14

Accepted Solution

by:
chinu1310 earned 500 total points
ID: 19600108
Well as above not possible without looping.
If interested in looping see this.
http://chiragrdarji.wordpress.com/2007/06/06/add-items-in-drop-down-list-or-list-box-using-javascript/

Hope it helps
0
 

Author Comment

by:Silas2
ID: 19600870
Thank you for that, but can you think of a way of overcoming the problem that I have: I have a grid/table where each row has a number of drop-downs in it, and each drop-down is extremely data-heavy.  I'm worried that if the Grid has too many rows and each row's drop-down is full that will make the page too big.
I was thinking of a solution where each drop-down is empty until, for example, it received focus and then it would be populated by JavaScript from a model so effectively all of the drop-downs will be empty until they receive focus, apart from the models.
0
 
LVL 9

Assisted Solution

by:sundaramkumar
sundaramkumar earned 500 total points
ID: 19606346
you add a onclick event for the row or onfocus event . attach a function to the event to load the drop downs with options
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question