jquery range slider - get values

I am using this jquery range slider: http://jqueryui.com/demos/slider/#range

How to I get the each value and print to the page?

See my code attached.

i.e.

I would like to get the lower value of the slider and print to <div id="LowerValue"></div> and the higher value and print to <div id="HigherValue"></div>

<script>
	$(function() {
		$( "#slider-range" ).slider({
			range: true,
			min: 32,
			max: 126,
			values: [ 32, 126 ],
			slide: function( event, ui ) {
				$( "#amount" ).val( ui.values[ 0 ] + "$ - " + ui.values[ 1 ] + "$" );
			}
		});
		$( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) + "$ - " + $( "#slider-range" ).slider( "values", 1 ) + "$" );
	});
</script>

Open in new window

petewinterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sudaraka WijesingheWeb Application ProgrammerCommented:
You need to change the function for the "slide" event. (And ofcause the initializing part at the bottom)
slide: function(event, ui) {
	$( "#LowerValue" ).val( ui.values[ 0 ] + "$" );
	$( "#HigherValue" ).val( ui.values[ 1 ] + "$" );
}

Open in new window

0
petewinterAuthor Commented:
Thanks, but it's not working for me. Can you please check my code?
<script>
	$(function() {
		$( "#slider-range" ).slider({
			range: true,
			min: 32,
			max: 126,
			values: [ 32, 126 ],
			slide: function( event, ui ) {
				$( "#amount" ).val( ui.values[ 0 ] + "$ - " + ui.values[ 1 ] + "$" );
				$( "#LowerValue" ).val( ui.values[ 0 ] + "$" );
				$( "#HigherValue" ).val( ui.values[ 1 ] + "$" );
			}
		});
		$( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) + "$ - " + $( "#slider-range" ).slider( "values", 1 ) + "$" );
		$( "#LowerValue" ).val( $( "#slider-range" ).slider( "values", 0 ) + "$" );
		$( "#HigherValue" ).val( $( "#slider-range" ).slider( "values", 1 ) + "$" );
	});
</script>


<div class="demo" style="width:95%">

<p>
	<label for="amount">Printer Width:</label>
	<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
</p>

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

</div><!-- End demo -->



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

<br /><br />

<div id="LowerValue"></div>
<div id="HigherValue"></div>

Open in new window

0
Sudaraka WijesingheWeb Application ProgrammerCommented:
Sorry, I didn't notice the #LowerValue and #HigherValue elements were DIV tags. Please use html() instead of val()
slide: function(event, ui) {
        $( "#LowerValue" ).html( ui.values[ 0 ] + "$" );
        $( "#HigherValue" ).html( ui.values[ 1 ] + "$" );
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
petewinterAuthor Commented:
Perfect. Many thanks
0
Sudaraka WijesingheWeb Application ProgrammerCommented:
Glad to help. Thanks for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.