有些人可以帮助解决这个问题,因为我无法解决这个问题。 Everythign工作正常,但由于某种原因,var mbdata中数组中的值的添加不能正确加起来。这是代码:
$(function() {
var labelArr = new Array(0, 20, 75, 1500);
$( "#slider" ).slider({
values: 0,
min: 0,
max: labelArr.length-1,
slide: function( event, ui ) {
mbdata=labelArr[ui.value]+labelArr[$( "#slider_2" ).slider("value")]+labelArr[$( "#slider_3" ).slider( "value" )]+labelArr[$( "#slider_4" ).slider( "value" )]+labelArr[$( "#slider_5" ).slider( "value" )]+labelArr[$( "#slider_6" ).slider( "value" )];
g1.refresh(mbdata);
}
});
});
$(function() {
var labelArr = new Array(0, 30, 75, 150);
$( "#slider_2" ).slider({
value:0,
min: 0,
max: labelArr.length - 1,
slide: function( event, ui ) {
mbdata=labelArr[ui.value]+labelArr[$( "#slider_3" ).slider( "value" )]+labelArr[$( "#slider" ).slider( "value" )]+labelArr[$( "#slider_4" ).slider( "value" )]+labelArr[$( "#slider_5" ).slider( "value" )]+labelArr[$( "#slider_6" ).slider( "value" )];
g1.refresh(mbdata);
}
});
});
$(function() {
var labelArr = new Array(0, 20, 100, 200);
$( "#slider_3" ).slider({
value:0,
min: 0,
max: labelArr.length - 1,
slide: function( event, ui ) {
$( "#days" ).val( ui.value );
$("#label_3").html(labelArr[ui.value]);
mbdata=labelArr[ui.value]+labelArr[$( "#slider_2" ).slider( "value" )]+labelArr[$( "#slider" ).slider( "value" )]+labelArr[$( "#slider_4" ).slider( "value" )]+labelArr[$( "#slider_5" ).slider( "value" )]+labelArr[$( "#slider_6" ).slider( "value" )];
g1.refresh(mbdata);
}
});
});
$(function() {
var labelArr = new Array(0, 10, 20, 50);
$( "#slider_4" ).slider({
value:0,
min: 0,
max: labelArr.length - 1,
slide: function( event, ui ) {
$( "#days" ).val( ui.value );
$("#label_4").html(labelArr[ui.value]);
mbdata=labelArr[ui.value]+labelArr[$( "#slider_2" ).slider( "value" )]+labelArr[$( "#slider" ).slider( "value" )]+labelArr[$( "#slider_3" ).slider( "value" )]+labelArr[$( "#slider_5" ).slider( "value" )]+labelArr[$( "#slider_6" ).slider( "value" )];
g1.refresh(mbdata);
}
});
});
$(function() {
var labelArr = new Array(0, 70, 140, 350);
$( "#slider_5" ).slider({
value:0,
min: 0,
max: labelArr.length - 1,
slide: function( event, ui ) {
$( "#days" ).val( ui.value );
$("#label_3").html(labelArr[ui.value]);
mbdata=labelArr[ui.value]+labelArr[$( "#slider_4" ).slider( "value" )]+labelArr[$( "#slider_3" ).slider( "value" )]+labelArr[$( "#slider_2" ).slider( "value" )]+labelArr[$( "#slider" ).slider( "value" )]+labelArr[$( "#slider_6" ).slider( "value" )];
g1.refresh(mbdata);
}
});
});
$(function() {
var labelArr = new Array(0, 60, 240,600);
$( "#slider_6" ).slider({
value:0,
min: 0,
max: labelArr.length - 1,
slide: function( event, ui ) {
$( "#days" ).val( ui.value );
$("#label_6").html(labelArr[ui.value]);
mbdata=labelArr[ui.value]+labelArr[$( "#slider_5" ).slider( "value" )]+labelArr[$( "#slider_4" ).slider( "value" )]+labelArr[$( "#slider_3" ).slider( "value" )]+labelArr[$( "#slider_2" ).slider( "value" )]+labelArr[$( "#slider" ).slider( "value" )];
g1.refresh(mbdata);
}
});
});
如果您想查看实时版本:http://www.rcb.com.mt/wordpresstesting/melita/calculator/Data-Calculator.html
答案 0 :(得分:0)
您在所有功能中使用相同的变量名称。声明新数组时,将覆盖旧数组。
尝试声明具有不同名称的数组。