【发布时间】:2014-05-21 05:46:57
【问题描述】:
我正在制作一个非常简单的系统来记录预订,除了“预订号”和“价格”部分是静态的之外,所有内容都是可编辑的。预订号是预定义的,价格是一个变量,取决于“选择的座位数”列的值。当我打开 .html 文件时,“价格”列始终显示为未定义,并且我想在相应地编辑“选择的座位数”后刷新代码。 The price which multiplies is also pre-defined and static, which would mean that when the number of seats chosen has been defined, it will be multiplied by 5. Here is my code:
<script type="text/javascript">
var seatvar = document.getElementsByClassName("seatchosen");
var pricepay = seatvar * 5
</script>
<script type="text/javascript">
function RefreshTable () {
var table = document.getElementById ("bookingtable");
table.refresh ();
}
</script>
<table class="editabletable" id="bookingtable" border="1">
<tr><th>Booking Number</th>
<th>Name</th>
<th>Number of Seats Chosen</th>
<th>Seats Chosen</th>
<th>Price</th>
</tr>
<tr><td>1</td>
<td><div contenteditable></div></td>
<td class="seatchosen"><div contenteditable></div></td>
<td><div contenteditable></div></td>
<td><script type="text/javascript">document.write(pricepay);</script></td></tr>
</table>
<p>Price Per Seat: £5</p>
<button onclick="RefreshTable()">Refresh the table</button>
该表仅显示一行,尽管有 20 行它们都遵循相同的代码。我也包括了标题。我不明白为什么我编辑了选择的座位数的值后它没有刷新。
【问题讨论】:
标签: javascript html html-table refresh