Cannot get JQuery slider to post its values


I'm trying to do some sliders (there will be about 5) but I want them to post the values somewhere on click of the submit button

For now just posting as a get to the same URL would be good but the code below doesnt seem to work

Any ideas please gurus?

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8">
	<title>jQuery UI Slider - Range slider</title>
	<link rel="stylesheet" href="css/base/jquery.ui.all.css">
    <script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/jquery.ui.core.js"></script>
	<script type="text/javascript" src="js/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="js/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="js/jquery.ui.slider.js"></script>
	#demo-frame > div.demo { padding: 10px !important; };
	$(function() {
		$( "#slider-range" ).slider({
			range: true,
			min: 0,
			max: 500,
			values: [ 0, 500 ],
			slide: function( event, ui ) {
				$( "#amount" ).val( "£" + ui.values[ 0 ] + " - £" + ui.values[ 1 ] );
		$( "#amount" ).val( "£" + $( "#slider-range" ).slider( "values", 0 ) +
			" - £" + $( "#slider-range" ).slider( "values", 1 ) );
		$("#slider-range").bind("slidechange", function(event, ui) {
    		$("#slider-hidden-sqm").attr('value', $("#slider-range").slider( "values", 0 ) + " - £" + $( "#slider-range" ).slider( "values", 1 ) );

<div class="demo">

<form method="get" action="search-test.html">
	<label for="amount">Price range:</label>
	<input type="text" id="amount" value="" />
    <input type="hidden" name="slider-hidden-sqm" value="" />
    <input type="submit" name="button" id="button" value="Submit">

<div id="slider-range"></div>


<div class="demo-description">

<p>Set the <code>range</code> option to true to capture a range of values with two drag handles.  The space between the handles is filled with a different background color to indicate those values are selected.</p>
</div><!-- End demo-description -->


Open in new window

Neil ThompsonSenior Systems DeveloperAsked:
Who is Participating?
Piotr DCommented:
You query the hidden input called "slider-hidden-sqm" with "#", which means you want to find a DOM element by its ID attribute. But you did not specified the iID attribute for that input ;)

Simply add an id attribute at line 44 and everything will work fine:

<input type="hidden" name="slider-hidden-sqm" id="slider-hidden-sqm" value="" />

Open in new window

Neil ThompsonSenior Systems DeveloperAuthor Commented:
suprb, thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.