struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Fletcher" <>
Subject RE: [OT] Help !! Too many select-box in one page
Date Tue, 10 May 2005 15:58:15 GMT

>>> but each select in each list has the same options.
If each select in each list has the same options, you can just download
the options once to a javascript array and populate all of the select
boxes on the client side.  A quick example:

<script language="JavaScript">
  var optionArray = {<c:out value="${myValuesCSV}" />};

  function populateBoxes() {
    var mySelectBox;
    // You'll need to do this for each box on your form
    for (var i = 0; i < optionArray.length; i++) {
      mySelectBox.options[i] = new Option(optionArray[i],

Call that populateBoxes function on startup.  Who knows how long that'll
take to populate client-side, but it should reduce your page size
considerably.  If you need different values than text in the select
boxes, you could either have a 2-dimensional array (which would require
different formatting for the values, or a different method of printing
them out in the javascript), or you could maintain 2 arrays, one for
values and one for text.  Note that you will need to know all of the
names of the select boxes unless you want to just loop through all of
the form elements and do the action for any of the select form elements
that you find.

Your CSV string that you drop into the optionArray will need to have
strings quoted if necessary of course.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message