ドロップダウンメニューからオプションを選択するたびに値を返すJavaScriptがあります。
$(document).ready(function() {
function calculateVals() {
//dropdown menus
var valuestart = $("select[name='timestart']").val();
var valuestop = $("select[name='timestop']").val();
//create date format
var timeStart = new Date("01/01/2007 " + valuestart).getHours();
var timeEnd = new Date("01/01/2007 " + valuestop).getHours();
var hourDiff = timeEnd - timeStart;
return hourDiff;
}
$("select").change(calculateVals);
calculateVals();
});
上記のスクリプトは、以下のjqueryプラグインに追加する必要のある数値を返します。オプションに追加する必要がありmax
ますが、エラーが発生しますcalculateVal is not defined
。
$(function(){
$("#slider").slider({
range: "min",
value: 8,
min: 1,
max: calculateVals(), //my attempt
step: 1,
slide: function(event, ui) {
$("#amount").text(ui.value);
},
stop: function(event, ui) {
$("#notifications").val(ui.value);
}
});
$("#notifications").val( $("#slider").slider("value") );
});