title: jQuery UI slider: multiple sliders with default values
body: <p>I have a page with multiple jQuery UI sliders on it. The sliders need to have a default value. For example, when somebody comes to my form, sets the slider, submits the form but they get an error the sliders should not reset back to 0. All of the previous elements of my form that they filled out should remain in place. I know you can set a default value for the slider but I'm having trouble getting it to work with multiple sliders. </p>
  
  <p>What I'm looking to do is take the value from the input field and use that as the default value for the range slider. You can see at the jsfiddle below I have the input's value's set to 2 and 4. When you load the page the sliders both go to the same position at 2.</p>
  
  <p>Somehow I need to tell the slider to get the value of the input that is directly below it and use that as the default.</p>
  
  <p>Any ideas on how to do this?</p>
  
  <p><a href="http://jsfiddle.net/dmcgrew/EquTn/3/" rel="nofollow">http://jsfiddle.net/dmcgrew/EquTn/3/</a></p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div class="kpa_rate kpa_rate1"&gt;
      &lt;label for="kpa1_rating_value"&gt;Rating 1:&lt;/label&gt;
  
      &lt;div id="1" class="slider"&gt;&lt;/div&gt;
      &lt;input type="text" class="kpa1_rating_value" name="kpa1_rating" value="2" /&gt;       
  &lt;/div&gt;
  
  
  &lt;div class="kpa_rate kpa_rate2"&gt;
      &lt;label for="kpa2_rating_value"&gt;Rating 2:&lt;/label&gt;
  
      &lt;div id="2" class="slider"&gt;&lt;/div&gt;
      &lt;input type="text" class="kpa2_rating_value" name="kpa2_rating" value="4" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>$(function() {
      $( ".slider" ).slider({
   range: "max",
   min: 0,
   max: 5,
   value: $("input", this).val(),
   slide: function( event, ui ) {                 
       //get the id of this slider
       var id = $(this).attr("id");
       //select the input box that has the same id as the slider within it and set it's value to the current slider value. 
           $("span[class*=" + id + "]").text(ui.value);
       $("input[class*=" + id + "]").val(ui.value);
   }
   });
  });
  </code></pre>