我很困惑为什么我的脚本在我的笔记本电脑上运行但在我把它放在服务器上时不起作用:
<HTML>
<HEAD>
<TITLE>Cubic Feet</TITLE>
<SCRIPT LANGUAGE="text/javascript">
function Calculate()
{
var qty1 = document.getElementById('q1').value;
var len1 = document.getElementById('l1').value;
var width1 = document.getElementById('w1').value;
var height1 = document.getElementById('h1').value;
var cube1 = (qty1*(len1*width1*height1))/1728;
var ss1 = cube1/53.3;
var qty2 = document.getElementById('q2').value;
if (qty2 =="") {
qty2=0
cube2=0
ss2=0;
}
var len2 = document.getElementById('l2').value;
var width2 = document.getElementById('w2').value;
var height2 = document.getElementById('h2').value;
var cube2 = (qty2*(len2*width2*height2))/1728;
var ss2 = cube2/53.3;
var qty3 = document.getElementById('q3').value;
if (qty3=="") {
qty3=0;
cube3=0;
ss3=0;
}
var len3 = document.getElementById('l3').value;
var width3 = document.getElementById('w3').value;
var height3 = document.getElementById('h3').value;
var cube3 = (qty3*(len3*width3*height3))/1728;
var ss3 = cube3/53.3;
var totcube = cube1 + cube2 + cube3;
var totskid = ss1 + ss2+ss3;
var tq = parseInt(qty1) + parseInt(qty2)+parseInt(qty3);
var trlft = totskid * 2;
var form = document.forms[0];
form.cuft1.value = cube1.toFixed(2);
form.sk1.value = ss1.toFixed(1);
form.cuft2.value = cube2.toFixed(2);
form.sk2.value = ss2.toFixed(1);
form.cuft3.value = cube4.toFixed(2);
form.sk3.value = ss4.toFixed(1);
form.totalcuft.value = totcube.toFixed(2);
form.sktotal.value = totskid.toFixed(1);
form.totalqty.value = tq.toFixed(1);
form.feet.value = trlft.toFixed(1);
}
function ClearForm(form)
{
form.q1.value = "";
form.l1.value = "";
form.w1.value = "";
form.h1.value = "";
form.cuft1.value = "";
form.q2.value = "";
form.l2.value = "";
form.w2.value = "";
form.h2.value = "";
form.cuft2.value = "";
form.q3.value = "";
form.l3.value = "";
form.w3.value = "";
form.h3.value = "";
form.cuft3.value = "";
form.totalcuft.value = "";
form.sktotal.value = "";
form.totalqty.value = "";
form.feet.value = "";
}
// end of JavaScript functions -->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="Calculator" METHOD="post">
Enter the quantity (number of pieces, skids, boxes, whatever) and their dimensions (length, width, height) in INCHES, then click Calculate.
<P><INPUT TYPE="button" VALUE="Calculate" name="AddButton" onClick="Calculate(this.form.q1.value, this.form.h1.value, this.form.w1.value, this.form.l1.value, this.form)">
<INPUT TYPE="button" VALUE="Clear" name="ClearButton" onClick="ClearForm(this.form)">
<p>
<table>
<tr>
<td> Container 1 Qty <input type="TEXT" id="q1" value="" size="5"></td>
<td> Length <input type="TEXT" id="l1" value="" size ="5"></td>
<td> Width <input type="TEXT" id="w1" value="" size = "5"></td>
<td> Height <input type="TEXT" id="h1" value="" size = "5"></td>
<td> Cu.Ft. <input type="TEXT" id="cuft1" value="" size = "5"></td>
<td> Skid spots <input type="TEXT" id="sk1" value="" size ="5"></td>
</tr>
<tr>
<td> Container 2 Qty <input type="TEXT" id="q2" value="" size="5"></td>
<td> Length <input type="TEXT" id="l2" value="" size="5"></td>
<td> Width <input type="TEXT" id="w2" value="" size="5"></td>
<td> Height <input type="TEXT" id="h2" value="" size="5"></td>
<td> Cu.Ft. <input type="TEXT" id="cuft2" value="" size="5"></td>
<td> Skid spots <input type="TEXT" id="sk2" value="" size="5"></td>
</tr>
<tr>
<td> Container 3 Qty <input type="TEXT" id="q3" value="" size="5"></td>
<td> Length <input type="TEXT" id="l3" value="" size="5"></td>
<td> Width <input type="TEXT" id="w3" value="" size="5"></td>
<td> Height <input type="TEXT" id="h3" value="" size="5"></td>
<td> Cu.Ft. <input type="TEXT" id="cuft3" value="" size="5"></td>
<td> Skid spots <input type="TEXT" id="sk3" value="" size="5"></td>
</tr>
<tr>
<td>Totals:</td>
</tr>
<tr>
<td> Total Qty <input type="TEXT" id="totalqty" value="" size="5"></td>
<td> Cu.Ft. <input type="TEXT" id="totalcuft" value="" size="5"></td>
<td> Skid spots <input type="TEXT" id="sktotal" value="" size="5"></td>
<td> Linear Feet <input type="TEXT" id="feet" value="" size="5"></td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
是什么导致它无法在服务器上运行?
没有错误消息。在我将其上传到服务器后点击计算时,没有生成答案。在当地完美运作。
感谢您一看。
答案 0 :(得分:0)
将cube4
替换为cube3
,ss4
替换为ss3
,text/javascript
替换为javascript
,并将<!--
替换为<SCRIPT>
}}
以下是这些替换后你应该得到的:
<HTML>
<HEAD>
<TITLE>Cubic Feet</TITLE>
<SCRIPT LANGUAGE="javascript">
<!--
function Calculate()
{
var qty1 = document.getElementById('q1').value;
var len1 = document.getElementById('l1').value;
var width1 = document.getElementById('w1').value;
var height1 = document.getElementById('h1').value;
var cube1 = (qty1*(len1*width1*height1))/1728;
var ss1 = cube1/53.3;
var qty2 = document.getElementById('q2').value;
if (qty2 =="") {
qty2=0
cube2=0
ss2=0;
}
var len2 = document.getElementById('l2').value;
var width2 = document.getElementById('w2').value;
var height2 = document.getElementById('h2').value;
var cube2 = (qty2*(len2*width2*height2))/1728;
var ss2 = cube2/53.3;
var qty3 = document.getElementById('q3').value;
if (qty3=="") {
qty3=0;
cube3=0;
ss3=0;
}
var len3 = document.getElementById('l3').value;
var width3 = document.getElementById('w3').value;
var height3 = document.getElementById('h3').value;
var cube3 = (qty3*(len3*width3*height3))/1728;
var ss3 = cube3/53.3;
var totcube = cube1 + cube2 + cube3;
var totskid = ss1 + ss2+ss3;
var tq = parseInt(qty1) + parseInt(qty2)+parseInt(qty3);
var trlft = totskid * 2;
var form = document.forms[0];
form.cuft1.value = cube1.toFixed(2);
form.sk1.value = ss1.toFixed(1);
form.cuft2.value = cube2.toFixed(2);
form.sk2.value = ss2.toFixed(1);
form.cuft3.value = cube3.toFixed(2);
form.sk3.value = ss3.toFixed(1);
form.totalcuft.value = totcube.toFixed(2);
form.sktotal.value = totskid.toFixed(1);
form.totalqty.value = tq.toFixed(1);
form.feet.value = trlft.toFixed(1);
}
function ClearForm(form)
{
form.q1.value = "";
form.l1.value = "";
form.w1.value = "";
form.h1.value = "";
form.cuft1.value = "";
form.q2.value = "";
form.l2.value = "";
form.w2.value = "";
form.h2.value = "";
form.cuft2.value = "";
form.q3.value = "";
form.l3.value = "";
form.w3.value = "";
form.h3.value = "";
form.cuft3.value = "";
form.totalcuft.value = "";
form.sktotal.value = "";
form.totalqty.value = "";
form.feet.value = "";
}
// end of JavaScript functions -->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="Calculator" METHOD="post">
Enter the quantity (number of pieces, skids, boxes, whatever) and their dimensions (length, width, height) in INCHES, then click Calculate.
<P><INPUT TYPE="button" VALUE="Calculate" name="AddButton" onClick="Calculate(this.form.q1.value, this.form.h1.value, this.form.w1.value, this.form.l1.value, this.form)">
<INPUT TYPE="button" VALUE="Clear" name="ClearButton" onClick="ClearForm(this.form)">
<p>
<table>
<tr>
<td> Container 1 Qty <input type="TEXT" id="q1" value="" size="5"></td>
<td> Length <input type="TEXT" id="l1" value="" size ="5"></td>
<td> Width <input type="TEXT" id="w1" value="" size = "5"></td>
<td> Height <input type="TEXT" id="h1" value="" size = "5"></td>
<td> Cu.Ft. <input type="TEXT" id="cuft1" value="" size = "5"></td>
<td> Skid spots <input type="TEXT" id="sk1" value="" size ="5"></td>
</tr>
<tr>
<td> Container 2 Qty <input type="TEXT" id="q2" value="" size="5"></td>
<td> Length <input type="TEXT" id="l2" value="" size="5"></td>
<td> Width <input type="TEXT" id="w2" value="" size="5"></td>
<td> Height <input type="TEXT" id="h2" value="" size="5"></td>
<td> Cu.Ft. <input type="TEXT" id="cuft2" value="" size="5"></td>
<td> Skid spots <input type="TEXT" id="sk2" value="" size="5"></td>
</tr>
<tr>
<td> Container 3 Qty <input type="TEXT" id="q3" value="" size="5"></td>
<td> Length <input type="TEXT" id="l3" value="" size="5"></td>
<td> Width <input type="TEXT" id="w3" value="" size="5"></td>
<td> Height <input type="TEXT" id="h3" value="" size="5"></td>
<td> Cu.Ft. <input type="TEXT" id="cuft3" value="" size="5"></td>
<td> Skid spots <input type="TEXT" id="sk3" value="" size="5"></td>
</tr>
<tr>
<td>Totals:</td>
</tr>
<tr>
<td> Total Qty <input type="TEXT" id="totalqty" value="" size="5"></td>
<td> Cu.Ft. <input type="TEXT" id="totalcuft" value="" size="5"></td>
<td> Skid spots <input type="TEXT" id="sktotal" value="" size="5"></td>
<td> Linear Feet <input type="TEXT" id="feet" value="" size="5"></td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
这在我的Firefox中运行正常。