Cannot get JQuery slider to post its values

Posted on 2011-10-13
Last Modified: 2012-05-12

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

Question by:NeilT
    LVL 3

    Accepted Solution

    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

    LVL 3

    Author Closing Comment

    suprb, thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    A common challenge, or question, when working with two calendar dates is: What is the difference between the specified days? As is frequently the case, the answer is: It depends... What kind of difference do you want? Given two date obje…
    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now