Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Cannot get JQuery slider to post its values

Hi

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?

Neil
<!DOCTYPE html>
<html lang="en">
<head>
	<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>
	<style>
	#demo-frame > div.demo { padding: 10px !important; };
	</style>
	<script>
	$(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 ) );
		});
	});
	</script>
</head>
<body>

<div class="demo">

<p>
<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">
</form>
</p>

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

</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 -->

</body>
</html>

Open in new window

0
Neil Thompson
Asked:
Neil Thompson
1 Solution
 
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

0
 
Neil ThompsonSenior Systems DeveloperAuthor Commented:
suprb, thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now