Reputation: 139
I'm trying to pass a jQuery variable through a Form, but I keep getting an error. How can I pass the values variable correctly. When I pass it to the next page, it spits out the intialized variable and does not change, when I change the slider. How can I get this to change?
<input id="column" type="hidden" name="column" value="";>
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
$( "#values" ).val(ui.values[ 0 ]);
}
});
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
$( "#column" ).val($( "#slider-range" ).slider( "values", 0 ));
});
</script>
Upvotes: 2
Views: 405
Reputation: 144689
your id selector is wrong, also please note you are setting the value of slider instead of getting, try this:
<input id="column" type="hidden" name="column" value="";/>
$("#column").val($("#slider-range").slider("value"));
or:
$("#slider-range").slider({
change: function(event, ui) {
$("#column").val($("#slider-range").slider("option", "value"));
}
});
Upvotes: 1
Reputation: 6030
I don't see any element with id="values", perhaps you want to pass the value to element with id="column"
$("#column").val($( "#slider-range" ).slider("value"));
and remove the value=values; part of the HTML code, simply value=""
Upvotes: 0
Reputation: 31131
First off, it's a good idea to put quotes around all of the values for attributes.
id=myTable --> id="myTable"
Second, your selector is wrong. The ID of the field is column
not values
$( "#column").val($("#slider-range").slider("values", 0));
Upvotes: 0