Ok so here's the problem. I suck at jquery but I'm trying to get better. I have a jquery ui range slider, works well. But I'm trying to add a change function so that when the values are changed, it puts the min age value into one text box, and the max age into another. Everything above the "change" block works fine, But as soon as i add the block from "change :" downwards to the code, slider fails to appear and I have an obvious error. I've tried this 20 different ways based on online tutorials and I just can't figure out why it's not working.
$( "#slider-range" ).slider({
range: true,
min: 18,
max: 90,
values: [ <?php echo htmlentities($row_loggedinUser['minAge']) ?>,<?php echo htmlentities($row_loggedinUser['maxAge']) ?> ],
slide: function( event, ui ) {$( "#amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );}}),
change: function(event, ui){
var x = document.getElementById('minAgeAmt');
x.value = $( "#slider-range" ).slider( "values", 0 );
var y = document.getElementById('maxAgeAmt');
y.value = $( "#slider-range" ).slider( "values", 1 );
};
********* EDIT ***********
Now thanks to Leighton it's working, just one issue . I now have this :
$( "#slider-range" ).slider({
range: true,
min: 18,
max: 90,
values: [ <?php echo htmlentities($row_loggedinUser['minAge']) ?>,<?php echo htmlentities($row_loggedinUser['maxAge']) ?> ],
slide: function( event, ui ) {$( "#amount" ).val("Age Range : " + ui.values[ 0 ] + " - " + ui.values[ 1 ]);},
change: function(event, ui) {
var x = document.getElementById('minAgeAmt');
x.value = $( "#slider-range" ).slider( "values", 0 );
var y = document.getElementById('maxAgeAmt');
y.value = $( "#slider-range" ).slider( "values", 1 );
}
});
Which works nice, but the bit where the #amount element is given a value only fires (obviously) when a change is made. How can I get it to also fire initially on page load? At the moment when the page loads it looks like this :
and as soon as I change the slider, :
I simply want the same caption generated on page load based on initial values

