Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML5 Range Sliders w/ jQuery occasionally not going to full max or min values
    primarykey
    data
    text
    <p>I have a fairly simple form with a single HTML5 range element in it (being rendered as a slider). The code for that looks like this:</p> <pre><code>&lt;form name="redform" id="redform" action="/"&gt; &lt;input id="id" name="id" type="hidden" value="&lt;?php echo $row['id']; ?&gt;" /&gt; &lt;input id="sliderRed" name="sliderRed" type="range" value="&lt;?php echo $data[5]; ?&gt;" min="0" max="255" /&gt; &lt;/form&gt; &lt;p class="note"&gt;Current value: &lt;span id="redValue"&gt;0&lt;/span&gt;&lt;/p&gt; &lt;div style="text-align:center; color:#FF0000" id="redresults"&gt;&lt;/div&gt; </code></pre> <p>Accompanying this is some jQuery that executes an external php script whenever the slider is moved:</p> <pre><code>$(function(){ var redValue = $('#redValue'); $('#sliderRed').change(function(){ redValue.html(this.value); }); $('#sliderRed').mouseup(function(){ $.post('process.php', $("#redform").serialize(), function(data) { $('#redresults').html(data); $('#redresults').fadeIn('slow').delay(2000).fadeOut('slow'); }); }); $('#sliderRed').change(); }); </code></pre> <p>All of that works. I can move the slider around, the value updates live, and the PHP script is run when the slider is released. Here's what's weird. The max and min values for the range slider are set to 0 and 255. However, sometimes, when dragging the slider all the way to one end, it will only hit 1 or 254. There doesn't seem to be any pattern to when this happens. Sometimes it goes to the full range, sometimes it can't go all the way. This is even the case while keeping you mouse held down and dragging it back and forth.</p> <p>If the max and min are changed to 256 and -1 respectively, similar behavior is observed. Sometimes it will max out at 256, and sometimes it will max out at 255. On the bottom end, it will sometimes hit -1, and sometimes it can only be dragged down to 0. This indicates to me that it doesn't have to do with actual numbers, but with some weird "off-by-one" bug.</p> <p>Any thoughts on this? I'm totally stumped...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload