Search code examples
javascriptjqueryhtmluislider

Tying an HTML slider 'max' range to an input field's value


How does one set the 'max' range value of a jQuery uiSlider to the value of a user editable input field?

Here is my example

<div data-role="page" id="page1">
  <div data-role="header" data-position="fixed">
   </div>
    <div>
<input name="Profit" id="Profit" value="How do I tie the 'max' range to this input field?" style="font-weight: bold;" />
<input name="label" id="label" value="deal" style="font-weight: bold;" />

</div>

<div role="main" class="ui-content">

  <ul data-role="listview">
    <li>
      <div id="SlideDesign">

      <input type="range" name="pSlider" id="pSlider" min="-1000" max="600" value="300" data-highlight="true" />
       </div>
     </li>
   </ul>
 </div>

Thanks!!


Solution

  • The following JavaScript is working

    document.getElementById("Profit").onchange = function() {MaxPCalculate()};   function MaxPCalculate() { var MaxProfit = document.getElementById("pSlider"); MaxProfit.max = document.getElementById("Profit").value; }
    

    ~Fiddle