这是 myFunctions 代码,但它不起作用。实际上它的初学者代码是因为我自学了我能做的事情。所有变量都在函数之前声明
原始编码已编辑。
它一直持续到我所拥有的表格中的所有管道尺寸和重量都被填满。它仅在我有 1 个 if 语句时才有效。猜猜我问的是它有什么问题。有没有更简单的方法来做到这一点。我有更多用于不同事物的表格,例如井筒套管。
这行不通
<head>
<title>Well Service Prevention</title>
<script>
var tubingSize;
var tubingWeight;
var tubingDisplacement;
var tubingCapacity;
function tubingTables(frm){
if (frm.tubingSize.value == 50.8){
tubingSize = 50.8
tubingWeight = 5.06
tubingDisplacement = 0.00065
tubingCapacity = 0.001413
alert("Tubing ID: " + tubingSize)
}
if (frm.tubingSize.value == 52.4){
tubingSize = 52.4
tubingWeight = 4.84
tubingDisplacement = 0.000622
tubingCapacity = 0.001554
alert("Tubing ID: " + tubingSize)
}
if (frm.tubingSize.value == 60.3 && frm.tubingWeight.value == 5.95){
tubingSize = 60.3
tubingWeight = 5.95
tubingDisplacement = 0.000765
tubingCapacity = 0.00211
alert("Tubing ID: " + tubingSize "Tubing Weight:" + tubingWeight)
}
}
</script>
</head>
<body>
<form name=known>
<h3>
Enter Known
</h3>
<p>Tubing ID: <input type="number" name="tubingSize">
<p>Tubing Weight: <input type="number" name="tubingWeight">
<p>Tubing Displacement: <input type="number" name="tubingDisplacement">
<p>Tubing Capacity: <input type="number" name="tubingCapacity">
<input type="button" value="Debug" onclick="tubingTables(this.form)">
</form>
</body>
删除最后一个 if 语句它有效。
<head>
<title>Well Service Prevention</title>
<script>
var tubingSize;
var tubingWeight;
var tubingDisplacement;
var tubingCapacity;
function tubingTables(frm){
if (frm.tubingSize.value == 50.8){
tubingSize = 50.8
tubingWeight = 5.06
tubingDisplacement = 0.00065
tubingCapacity = 0.001413
alert("Tubing ID: " + tubingSize)
}
if (frm.tubingSize.value == 52.4){
tubingSize = 52.4
tubingWeight = 4.84
tubingDisplacement = 0.000622
tubingCapacity = 0.001554
alert("Tubing ID: " + tubingSize)
}
}
</script>
</head>
<body>
<form name=known>
<h3>
Enter Known
</h3>
<p>Tubing ID: <input type="number" name="tubingSize">
<p>Tubing Weight: <input type="number" name="tubingWeight">
<p>Tubing Displacement: <input type="number" name="tubingDisplacement">
<p>Tubing Capacity: <input type="number" name="tubingCapacity">
<input type="button" value="Debug" onclick="tubingTables(this.form)">
</form>
</body>
现在也在努力在 Firefox 中获取调试器。有什么建议吗?