title: Setting the value of a JQuery SelectBox to the variable from a Model
body: <p>I've got a jquery selectbox that I use to give users options for filtering a page. The default value is 'All' and then there are a series of options they can choose. </p>
  
  <p>When they make their selection, the page gets reloaded with their selection and then I want the selectbox to display their selection. The problem is that I can't seem to get the selectbox value to set to the previously selected value.</p>
  
  <p>The HTML for the selectbox looks like this:</p>
  
  <pre><code>&lt;select id="mySelectMenu"&gt;
      &lt;option value="VALUEALL"&gt;All&lt;/option&gt;
      &lt;option value="VALUE1"&gt;A&lt;/option&gt;
      &lt;option value="VALUE2"&gt;B&lt;/option&gt;
      &lt;option value="VALUE3"&gt;C&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The value they choose is saved in my model so I have the following at the top of my jspx page:</p>
  
  <pre><code>&lt;c:set value="${myModel.myFilterCriteria}" var="myFilterValue" /&gt;
  </code></pre>
  
  <p>This is in my document.ready</p>
  
  <pre><code>$(function() {
      $( "#mySelectMenu" ).selectBox();
      // this is how I've tried to force my value to 'A' instead of 'All', but it 
      // didn't work.
      $("#mySelectMenu option[value='VALUE1']").prop("selected", true);
  
      // I'd like to be able to use something like this: 
      $("#mySelectMenu option[value='(myFilterValue)']").prop("selected", true);
  });
  </code></pre>
  
  <p>I've tried various ways to get it set to 'myFilterValue', but can't seem to get it set. </p>
  
  <p><strong>--- FOUND THE RESOLUTION ---</strong></p>
  
  <p>The issue was the following in my function </p>
  
  <pre><code>$( "#mySelectMenu" ).selectBox();
  </code></pre>
  
  <p>I removed it and added the following and it worked.</p>
  
  <pre><code>$("#mySelectMenu option[value='${myFilterValue}']").prop("selected", true);
  </code></pre>
  
  <p>So, my function now looks like this:</p>
  
  <pre><code>$(function() {
      $("#mySelectMenu option[value='${myFilterValue}']").prop("selected", true);
  });
  </code></pre>
  
  <p>Thank you all for your help!</p>