i have a problem with accessing global variables, would like to access
selection1 = $("#slider").slider( "value" );
selection2 = $("#slider2").slider( "value" );
inside the jQuery function simply by calling the calcTmpl(selection1, selection2) with the selections but this does not seem to work by declaring the variable outside the function like so: var selection1 = $("#slider").slider( "value" );
the slider then dissapears.
this is the code for the calculations the sliders perform. And this works, just that i dont want to keep setting the selection1 and 2 over and over again.
Any ideas why this isnt working?
var selection1;
var selection2;
$("#slider").slider({
range: "min",
value: 5000000,
min: 100000,
max: 10000000,
slide: function() {
selection1 = $("#slider").slider("value");
selection2 = $("#slider2").slider("value");
calcTmpl(selection1, selection2);
},
change: function() {
selection1 = $("#slider").slider("value");
selection2 = $("#slider2").slider("value");
calcTmpl(selection1, selection2);
}
});
$("#slider2").slider({
range: "min",
value: 50000,
min: 100,
max: 100000,
slide: function() {
selection1 = $("#slider").slider("value");
selection2 = $("#slider2").slider("value");
calcTmpl(selection1, selection2);
},
change: function() {
selection1 = $("#slider").slider("value");
selection2 = $("#slider2").slider("value");
calcTmpl(selection1, selection2);
}
});
calcTmpl(5000000,50000);
Try this instead: