我正在使用两个滑块创建一个储蓄计算器。有两个输入(学生人数和小组规模)和两个输出(节省金钱和节省时间)。我附上了一张图片以供参考。计算正在运行,但是当我移动滑块时,我必须点击刷新才能看到新的答案。相反,我希望我的答案随着我移动滑块而改变。
我在这个站点工作,但对计算进行了更改:http: //egorkhmelev.github.com/jslider/
我希望它最终看起来如何:
<div class="layout">
<div class="layout-slider" style="width: 20%">
<input id="SliderSingle" type="slider" name="kids" value="20" />
<script type="text/javascript" charset="utf-8">
jQuery("#SliderSingle").slider({
from: 1,
to: 1000,
step: 1,
round: 1,
format: {
format: '0',
locale: 'de'
},
dimension: ' Kids',
});
var numkids = $("#SliderSingle").slider("value");
</script>
</div>
<div class="layout-slider" style="width: 20%">
<input id="Slider" type="slider" name="group" value="20" />
<script type="text/javascript" charset="utf-8">
jQuery("#Slider").slider({
from: 1,
to: 5,
step: 1,
round: 1,
format: {
format: '0',
locale: 'de'
},
dimension: ' Kids',
});
var groupsize = $("#Slider").slider("value");
</script>
</div>
<script type="text/javascript" charset="utf-8">
var timesaved = (numkids * 65) / groupsize;
var moneysaved = timesaved * 60;
document.write(timesaved + "hrs ");
document.write(" | " + numkids + " | ");
document.write("$" + moneysaved);
</script>
<div>
任何帮助是极大的赞赏。