title: using jquery to find mvc listbox for selected items
body: <p>I have a view and a loop within which a partial view is rendered. With the partial view I have a multi select listbox. So based on count of a item in the loop there could (n) number of listboxes.</p>
  
  <p>My goal is to get all the selected items if any from the first listbox and pre-select them in the remainder of the listboxes. I am not trying to append to the remaining listboxes but just whatever is selected in the first, i would select in the remaining. all the listboxes will have the same items in them.</p>
  
  <p>I am facing diffculty to find the selected indexes or items only from the first one and then i will do the preselection in the remaining, if i could just get the indexes of the selected items in the first one would be helpful.  It gives selected  items from all the listboxes. please help:</p>
  
  <p>listbox decleration within the partial view</p>
  
  <pre><code> @Html.ListBoxFor(model =&gt; model.ServiceTypes,
             new MultiSelectList(RunLog.Domain.Lists.GlobalList.PartsServiceTypes(), "ID", "Name"),
             new {
                 style = "width: 200px; height: 80px;",
                 id = "lstbox",
                 name = "listbox"
             })
  </code></pre>
  
  <p>button which renders the function</p>
  
  <pre><code>&lt;input id="button" type="button" class="art" onclick="dosomething()" name="broadcast"  value="+" /&gt;
  </code></pre>
  
  <p>JS Function:</p>
  
  <pre><code>function broadcast() {
      //var element = $('select[multiple]'); This gives me access of all listboxes
      // var firstListBoxSelected = $('select[multiple][1] option:selected').text(); t
  }
  </code></pre>