【发布时间】:2013-12-31 04:02:49
【问题描述】:
我正在尝试制作一个表格,用户可以在其中填写一些单元格的值,然后单击提交以显示计算结果。我的目录中有 jquery-2.0.3.min.js 和 script.js。这是我的 HTML 代码:
<!DOCTYPE html>
<html>
<head>
<title>Inteligence Decision Support System</title>
<script src='localhost/idss/jquery-2.0.3.min.js'></script>
<script type="text/javascript" src='localhost/idss/script.js' charset="utf-8"></script>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Cost</th>
<th>x20</th>
<th>x25</th>
</tr>
<tr>
<td>someName</td>
<td><input name="Cost" type="text" value="0"></td>
<td><input name="a20" type="text" value=""></td>
<td><input name="a25" type="text" value=""></td>
</tr>
</table>
<input type="button" onclick="Zcount()" value="Submit" >
</body>
</html>
这里是 script.js 文件
<script type="text/javascript">
function Zcount(){
var cost, a20, a25;
a20 = document.getElementById("a20").value;
a25 = document.getElementById("a25").value;
cost = (2*parseInt(a20))+(3*parseInt(a25));
document.getElementById("Cost").value=cost;
}
</script>
但是当我填写 a20 和 a25 并单击提交按钮时,什么也没发生。结果保持为零。我哪里做错了?
【问题讨论】:
-
这和xampp有什么关系?
-
我试图弄清楚我调用脚本文件的方式是否错误,或者我应该将它放在 xampp 文件夹中的其他位置。无论如何,我只是试图将脚本放在我的 html 代码中,但这也不起作用。
标签: javascript html xampp localhost