javascript - Getting variables from a Bootstrap slider -
i have variable price range slider webshop. want echo value in php. code in test.php file:
<script> var slidervalue = $('#output').val(); </script> <?php echo "<script>document.writeln(slidervalue);</script>"; ?>
and code in bootstrap-slider.js file:
$(function() { $("#pricelimit") .slider({}) .on('slide', function() { $('#output').html(this.value); }) .trigger('slide'); });
and code of slider itself:
<input id="pricelimit" type="text" class="span2" value="" data-slider-min="10" data-slider-max="200" data-slider-step="5" data-slider-value="[20,100]"/>
however, on page, says 'undefined'. going wrong here?
first, make sure have included jquery library in test.php or if included in file, check if jquery included there too.
then, remove var var slidervalue = $('#output').val();
from test.php.
also can directly access value using php's $_get['somename']
first adding "name" attribute in input. name="somename"
Comments
Post a Comment