埋め込みJavaScriptコードで動作するonclickイベントを取得しようとしています。onclickイベントがJavascriptで機能する関数を取得できません
私はイベントハンドラを登録し、非常に多くのフォーラムや書籍に相談した後で、機能を完了させるためにコードを修正する方法をいくつか試しました。
私はそれが何かシンプルだと確信していますが、私はそれが問題になっているかどうかを知るには近すぎます!誰かがアドバイスする時間がかかる場合は、私は最も感謝します!
はここで、HTML文書からの抜粋です:
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Order Form</title>
<script type = "text/javascript">
function updateTotal() {
var boltQty = document.getElementbyId("bolt_quantity").value;
var nutQty = document.getElementbyId("nut_quantity").value;
var washQty = document.getElementbyId("wash_quantity").value;
document.getElementById("subtotal").value =
totalCost = (2.15 * boltQty) + (0.45 * nutQty) + (0.15 * washQty);
}
</script>
</head>
<body>
<h3>Order Form</h3>
<form id = "orderform" action = "">
<table border = "1" cellpadding = "3">
<tr>
<th colspan = "8">Product details</th>
</tr>
<tr>
<th>Item</th>
<th>Product Code</th>
<th>Diameter</th>
<th>Length</th>
<th>Colour</th>
<th>Unit Price</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<tr>
<td>Bolt</td>
<td>B113</td>
<td>9</td>
<td>50</td>
<td>Black</td>
<td>2.15</td>
<td><input type = "text" id = "bolt_quantity" size = "3" /></td>
<td><input type = "text" id = "row1" onfocus = "this.blur();" size = "3" /></td>
</tr>
<tr>
<td>Nut</td>
<td>N234</td>
<td>5</td>
<td>n/a</td>
<td>Silver</td>
<td>0.45</td>
<td><input type = "text" id = "nut_quantity" size = "3" /></td>
<td><input type = "text" id = "row2" onfocus = "this.blur();" size = "3" /></td>
</tr>
<tr>
<td>Washer</td>
<td>W359</td>
<td>8</td>
<td>n/a</td>
<td>Silver</td>
<td>0.30</td>
<td><input type = "text" id = "wash_quantity" size = "3" /></td>
<td><input type = "text" id = "row3" onfocus = "this.blur();" size = "3" /></td>
</tr>
</table>
<p>
<input type = "button" value = "Subtotal" onclick = "updateTotal();" />
<input type = "text" size = "3" id = "subtotal" onfocus = "this.blur();" />
</p>
<p>
<input type = "submit" value = "Submit Order" />
<input type = "reset" value = "Clear Order Form" />
</p>
</form>
</body>
</html>
何が問題なのですか?あなたは間違いをしているのですか、あなたの結果はあなたが期待しているものではありませんか? – Terry