I got 2 jQUERY functions - and i want to pass a variable from the first to the second. From what i read i need to set the variable as a global variable, but the methods i read and try to reproduce doesn't seem to work.
$(function() {
$("#selectable").selectable({
stop: function() {
$(".ui-selected", this).each(function() {
var index = $("#selectable li").index(this); });}});});
$(function() {
$("#slider-range").slider({
range: true,
min: 0,
max: 180,
values: [0, 180],
slide: function(event, ui) {
var result = $("#result").empty();
var low = (ui.values[0]);
var high = (ui.values[1]);
HERE I NEED THE VARIABLE FROM THE ABOVE FUNCTION
$.post('search.php',{low: (ui.values[0]), high: (ui.values[1]), HERE I NEED VARIABLE FROM THE ABOVE FUNCTION},
function(data){
result.append(data);
});
- I have tried to do like this:
FIRST METHOD - Seen here : http://www.quirksmode.org/js/function.html
setting variable : example(index);
retrieveing variable : function example(a) {index = a};
This i can't get to work.. the functions breaks when i try to include the index as the variable in the $.post.
SECOND METHOD Not fully aware about this method, but this seems like a solution, if fully understood: document.write() - But i can't seem to get to know how to retrieve it again.
Hope somebody has a solution for this as i have had tried a load of things to try to pass this rather simple thing on to the next function.
Thanks in advance.