我试图隐藏一个excel电子表格,其中有多个依赖于运行某些Calc的输入。和依赖显示其输入中的总和。但是我遇到了麻烦,而且一些结果也令人困惑,试图将所有这些功能插入其输入中。任何帮助将不胜感激。
HTML
<input class="" id="avg-pumping-distance" type="number" value="30000"/>
<br/>
<h3 style="margin: 50px 0 0px;">Output</h3>
<input style="margin: 0px 0 0px;" class="" id="num1" type="number" value="0">
<br/>
<input style="margin: 20px 0 0px;" class="" id="num2" type="number" value="0">
<br/>
<input style="margin: 20px 0 0px;" class="" id="num3" type="number" value="0">
的JavaScript
var ReserveFloatingPipe = function() {
var val = 100
var val2 = 4400
var val3 = 100
var val4 = (val2 - val3) * val;
var val5 = val * val4;
var total = val5 / 1000;
$('#num1').val(total);
return total;
};
ReserveFloatingPipe();
// console.log(ReserveFloatingPipe());
var ReserveSubPipe = function() {
var val = 100
var val2 = 5400
var val3 = 100
var val4 = (val2 - val3) * val;
var val5 = val * val4;
var total = val5 / 1000;
$('#num2').val(total);
return total;
};
ReserveSubPipe();
var ReserveShorePipe = function() {
var val = 562
var val2 = 652
var val3 = 8500
var val4 = (val2 - val3) * val;
var total = val4 / 100;
$('#num3').val(total);
return total;
};
ReserveShorePipe();
// console.log(ReserveShorePipe());
document.getElementById("avg-pumping-distance").onchange = (function () {
ReserveFloatingPipe();
ReserveSubPipe();
ReserveShorePipe();
});
答案 0 :(得分:0)
你的改变功能受到你的平均抽水距离的限制。元素存在之前的input元素。您需要使用文档就绪函数将函数绑定到元素。
$(function(){
document.getElementById("avg-pumping-distance").onchange = (function () {
ReserveFloatingPipe();
ReserveSubPipe();
ReserveShorePipe();
});
});
或
$(function(){
$("#avg-pumping-distance").on('change',function(){
ReserveFloatingPipe();
ReserveSubPipe();
ReserveShorePipe();
});
});
或
$( document ).ready(function() {
document.getElementById("avg-pumping-distance").onchange = (function () {
ReserveFloatingPipe();
ReserveSubPipe();
ReserveShorePipe();
});
});
或
$( document ).ready(function() {
$("#avg-pumping-distance").on('change',function(){
ReserveFloatingPipe();
ReserveSubPipe();
ReserveShorePipe();
});
});