title: Jquery form serialize - Multiple select on jqgrid
body: <p>I have a jqGrid where I am sending a string value to the colmodel for a particular property called "<strong>equipments</strong>". Everything is ok so far as the value is showing perfectly on the grid.
  I have also added an Add and Edit button and all is well and working fine, the forms are showing as expected. (Forgive the apparantly long post but its extremely easy to follow)</p>
  
  <p>I modified field called equipments on the add form and injected my very own multiple select like this</p>
  
  <p><strong>colModel</strong></p>
  
  <pre><code>            {name:'equipments',index:'equipments', width:6, editable:true, edittype:'custom',
                editoptions:{
                    custom_element:function(){                                  
                          return $('&lt;div id="mytrensferselect"&gt;&lt;div class="transfer"&gt;&lt;select id="select1" multiple="multiple"&gt;&lt;/select&gt;&lt;a href="#" id="addbutton"&gt;add&lt;/a&gt;&lt;/div&gt;&lt;div class="transfer"&gt;&lt;select id="select2" multiple="multiple"&gt;&lt;/select&gt;&lt;a href="#" id="removebutton"&gt;remove&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;');  
                        },
                        custom_value:function(ele){
                                  return ele.val();           
                        }                               
                    }                           
              }
  </code></pre>
  
  <p><strong>Add Button - beforeShowForm option</strong></p>
  
  <pre><code>                    bSubmit: "Save and New",
                      bCancel: "Cancel",
                      beforeShowForm: function(form) {
                              $.get('&lt;c:url value="/moduleinstances/retrieveequipments?miId="/&gt;' , function(data){  //load in my list of equipments as json string
                                  var obj = jQuery.parseJSON(data);  //parse the resulting json in order to populate select1 and select2
                              $("#select1").html(obj.remaining);
                              $("#equipments").removeAttr("name").removeAttr("id").removeClass("customelement");
                              $("#select2").html(obj.owning).attr("name","equipments").attr("id","equipments").addClass("customelement");
                              $('#addbutton').click(function() {
                                  return !$('#select1 option:selected').remove().appendTo('#equipments');
                              });
                              $('#removebutton').click(function() {
                                  return !$('#equipments option:selected').remove().appendTo('#select1');
                              });
                              }); //End AJAX CALL abd CUSTOM Transfer Select logic
  
  //Start Logic For Custom Save and Close Button
  
                          $('&lt;a href="#"&gt;Save and Close&lt;span class="ui-icon ui-icon-disk"&gt;&lt;/span&gt;&lt;/a&gt;').click(function() {
                              if($.isNumeric($(form.selector+" #rateOfPay").val())){
                                  $.post('&lt;c:url value="/moduleinstances/create/${courseModule.id}"/&gt;', $('#FrmGrid_list2').serialize() , function(data){
                                      $('#list2').trigger("reloadGrid");
                                      $("#cData").trigger('click');
                                  }); 
                              }else{
                                      alert("Pay Rate must be numeric");
                              }                      
                          }).addClass("fm-button ui-state-default ui-corner-all fm-button-icon-left")
                          .prependTo("#Act_Buttons&gt;td.EditButton");
                          $('#title').attr('value','${courseModule.name}'); 
                          $("#leadLecturer").val( '${lecturer.id}' );
                      }
  </code></pre>
  
  <p>Here is the relevant part of my add form.</p>
  
  <p><img src="https://i.stack.imgur.com/SKZvH.png" alt="enter image description here"></p>
  
  <p>The functionality is working fine when I click on <strong>Save and New</strong> which is the submit button I decleared via <code>bSubmit: "Save and New"</code> above. The postdata for this is shown on your left. When I click on the <code>Save and close</code> button which is my custom button. The post data is shown on your right.</p>
  
  <p><img src="https://i.stack.imgur.com/EN96N.png" alt="enter image description here"></p>
  
  <p>The Save and Close uses jquery to serialize the entire form like this <code>$('#FrmGrid_list2').serialize()</code>, this is where it gets hairy. </p>
  
  <p>If we look at what was posted for equipments in both cases we can see the name difference. It seems like jqGrid is intelligent enough to figure out its an array of values, while jquery serialize() didn't in the way i want it to. I am using Spring MVC 3.0 and here is where my equipments data goes to the action.</p>
  
  <pre><code>@RequestMapping(value = "update", method = RequestMethod.POST)
  public @ResponseBody String update(Model uiModel,
          @RequestParam("id") Long mId,
          @RequestParam("campus") Long cId,
          @RequestParam("leadLecturer") Long lId,//This is actually a Person ID.
          @RequestParam("semesterStartDate") @org.springframework.format.annotation.DateTimeFormat(pattern = "MMMM dd, yyyy") java.util.Calendar semesterstartdate,
          @RequestParam("semesterEndDate") @org.springframework.format.annotation.DateTimeFormat(pattern = "MMMM dd, yyyy") java.util.Calendar semesterenddate,
          @RequestParam("tuitionStartDate") @org.springframework.format.annotation.DateTimeFormat(pattern = "MMMM dd, yyyy") java.util.Calendar tuitionstartdate,
          @RequestParam("tuitionEndDate") @org.springframework.format.annotation.DateTimeFormat(pattern = "MMMM dd, yyyy") java.util.Calendar tuitionenddate,
          @RequestParam("rateOfPay") Double rateOfPay,
          @RequestParam("equipments[]") ArrayList&lt;String&gt; equipments,
          HttpServletRequest httpServletRequest) { Bla...bla...bla }
  </code></pre>
  
  <p>Look at the very last <strong>@RequestParam</strong>, Spring is capable of handling the array of items, but when it gets posted with jQuery serialize, the action cannot find the paramiter called "<strong>equipments[]</strong>"
  I saw a link <a href="http://www.craiglotter.co.za/2010/06/28/jquery-and-ajax-how-to-send-all-selected-values-from-a-multiple-select-box/" rel="nofollow noreferrer">here</a> about this, can I simply do this instaed?</p>
  
  <p>Any ideas</p>