title: iterating through java collection using jQuery
body: <p>I am starting with this object,</p>
  
  <pre><code>public class myTO {
  
      private String id;
      private String name;
      }
  </code></pre>
  
  <p>Which is used in this object</p>
  
  <pre><code>public myCombiTO {
      private myTO myTO;
  
      private List&lt;String&gt; valueList;
      private List&lt;String&gt; displayList;
  }
  </code></pre>
  
  <p>I create a list of these objects</p>
  
  <pre><code>List&lt;myCombiTO&gt; myCombiTOList = getMyCombiTOList();
  </code></pre>
  
  <p>I use this list to set a jsp page attribute</p>
  
  <pre><code>request.setAttribute("myAttrList", myCombiTOList);
  </code></pre>
  
  <p>And forward to the jsp page. I then use jquery and jstl to populate a drop down from this list</p>
  
  <pre><code>&lt;select name="mYSelect" id="mySelect"&gt;
       &lt;c:forEach var="myVar" items="${myAttrList}"&gt;
            &lt;option value="${myVar.myTO.id}" &gt;
                 &lt;c:out value="${myVar.myTO.name}" /&gt;
            &lt;/option&gt;
      &lt;/c:forEach&gt;    
  &lt;/select&gt;
  </code></pre>
  
  <p>My problem is I want to populate a second drop down using jquery with the values from mycombiTO.getValueList(). so far I have this</p>
  
  <pre><code>$("#mySelect").change(function(){
          var myJSList = ${myAttrList};
          var chosenGroup = $("#mySelect").val();
          var valueArray = myJSList.get(chosenGroup).valueList;
          var displayArray = myJSList.get(chosenGroup).displayList;
          var items = {'display':[displayArray], 'value':[valueArray]};
  
          //now populate drop downs
  
          $.populateSelect($('#myselect').get(0), items);
  
      });
  
  jQuery.populateSelect = function(element,items) {
      $.each(items, function() {
              element.options[element.options.length]  = new Option(this.display,this.value);
            });
  };
  </code></pre>
  
  <p>However its not working please help.  I am having trouble creating the javascript object based on two arrays.  Hwoever ideally I would want to reference a java map from jquery using key/value pairs. Is this possible ?</p>
  
  <p>Thanks in advance.</p>