0
我的JavaScript代碼不工作,因爲當我點擊按鈕時沒有任何東西顯示出來。有人知道解決方案嗎?我已經嘗試拿出代碼並將按鈕的格式設置爲alert(...)
,並且它可以工作,所以現在我被卡在數學方程式上了。我很積極,儘管我沒有錯過任何括號或標點符號。感謝您的反饋和幫助。Java Script Mathmatic Equation
<!DOCTYPE html>
<html>
<head>
<title>Project</title>
<style type="text"/css>
.inbox
{
width=30px;
text-align: right;
border: 2px solid black;
}
.align
{
text-align: right
}
</style>
<script type="text/javascript">
function compute() {
var a = form1.inputA.value;
a = parseFloat(a);
var b = form1.inputB.value;
b = parseFloat(b);
var c = form1.inputC.value;
c = parseFloat(c);
var e = a * 5.49;
form1.sumA.value = e.toFixed(2);
}
function pageInit()
{
form1.inputA.focus();
}
</script>
</head>
<body onload="pageInit();">
<form id="form1">
<table border="2" >
<tr>
<th colspan="4">Sample Order Form</th>
</tr>
<tr>
<th>Quantity</th>
<th>item</th>
<th>Unit Price</th>
<th>Totals</th>
</tr>
<tr>
<th>
<input tabindex="1" class="inbox" type="text" id="inputA" />
</th>
<th>Apples</th>
<td>$5.49</td>
<th>
<input class="inbox" type="text" id="sumA" readonly="readonly" />
</th>
</tr>
<tr>
<th>
<input tabindex="4" type="button" value="Compute" onclick="compute();" />
</th>
</tr>
</table>
</form>
</body>
</html>
所以是java或JavaScript的? – 2014-10-30 05:40:12
它是javascript – 2014-10-30 05:53:19
您應該重新格式化您的問題 – 2014-10-30 06:01:24