How to pass PHP variable value to jquery function?

i have this JQuery Script in WordPress /js folder and i need to change some values that i store in the Database.$( “#slider-range2″ ).slider( range: true, min: 18, max: 90, values: [ 35, 50 ], slide: function( event, ui ) $( “#amount2″ ).val( ui.values[ 0 ] + “-” + ui.values[ 1 ] ); });…

via PHP Website Development » Search Results » ajax:

How to pass PHP variable value to jquery function?

i have this JQuery Script in WordPress /js folder and i need to change some values that i store in the Database.
$( “#slider-range2″ ).slider(
range: true,
min: 18,
max: 90,
values: [ 35, 50 ],
slide: function( event, ui )
$( “#amount2″ ).val( ui.values[ 0 ] + “-” + ui.values[ 1 ] );

});
$( “#amount2″ ).val( $( “#slider-range2″ ).slider( “values”, 0 ) + “-” + $( “#slider-range2″ ).slider( “values”, 1 ) );The Jquery documentation is not clear to me. Values that i need to change are [35 , 50]. These values ??are stored in the database. How can i do this from the js file? How can i pass a PHP variable value to jquery function?
Thanks.
………………………………….

I’d say you just do it like this:
$( “#slider-range2″ ).slider(
range: true,
min: 18,
max: 90,
values: [ , ],
slide: function( event, ui )
$( “#amount2″ ).val( ui.values[ 0 ] + “-” + ui.values[ 1 ] );
});
where of course $value1 and $value2 are the values you get from the database.
-edit- or what the other guy said, you can use a php for loop to make the size of your array dynamic that way :)
………………………………….

Assuming you want to keep the external js file and not embed it into your php script, have php write out two global js vars, and modify the js file to use those instead.
e.g. in php:
echo ““;and in your js file:
values: [val1, val2]

But if you can change your js file to be a php file instead, you can do something like:

… // your regular js code here
values: ,
…Now, you can use on your page: