Retrieving Variables from the Bootstrap Slider

I need to get a variable from the price range slider for my online store. I want to repeat the value in PHP. This is the code in the test.php file:

<script> var slidervalue = $('#output').val(); </script> <?php echo "<script>document.writeln(slidervalue);</script>"; ?> 

And this is the code in the bootstrap-slider.js file:

 $(function() { $("#pricelimit") .slider({}) .on('slide', function() { $('#output').html(this.value); }) .trigger('slide'); }); 

And this is the code of the 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, the page says 'undefined'. What is wrong here?

+5
source share
1 answer

First, make sure you include the jQuery library in test.php, or if it is included in another file, check if jQuery is included.

Then remove var from var slidervalue = $('#output').val(); from test.php.

You can also directly access the value with php $_GET['somename'] first adding the "name" attribute. name="somename"

0
source

All Articles