我试图将表单的这一部分放在div和id = loan中以使其消失。
为了排除故障,我把TESTTEXT1放在div元素之后,它做我想做的事情(当用户单击单选按钮时消失),但是TESTTEST2和更高版本似乎不受用户操作的影响。有人知道为什么会这样吗?
HTML:
<header>
<script>
function checkA(){
document.getElementById('loan').style.display='none';
document.getElementById('assigned').style.display='block';
}
function checkL(){
document.getElementById('assigned').style.display='none';
document.getElementById('loan').style.display='block';
}
</script>
</header>
<body>
<table>
<td>
<input type="radio" onclick='checkA()' name="toloan" id="0" value="0"/> <label for="0">To assign</label>
<input type="radio" onclick='checkL()' name="toloan" id="1" value="1"/> <label for="1">To loan</label>
</td>
<div id="loan">
TESTTEXT1
<tr>
<th>
<label for="borrowing_month">Borrowing date</label>
</th>
<td>
<select name="borrowing_month" id="borrowing_month">
<option value ='1' selected="selected">
TEST
</option>
</select>
<select name="borrowing_day" id="borrowing_day">
<option value="2" selected="selected">
</select>
<select name="borrowing_year" id="borrowing_year">
<option value="3" selected="selected">
</select>
</td>
</tr>
<tr>
<th>
<label for="return_month">Return date</label>
</th>
<td>
<select name="return_month" id="return_month">
<option value="4" selected="selected">
</option>
</select>
<select name="return_day" id="return_day">
<option value="5" selected="selected">
</select>
<select name="return_year" id="return_year">
<option value="6" selected="selected">
</select>
</td>
</tr>
</div>
</table>
</body>好的,我试着根据请求删除所有的php。
发布于 2017-05-31 14:59:46
正如@DanielBeck所指出的,没有表包装器,所以我会尝试将<div id="loan">更改为<table id="loan">。
当然,您必须将结束标记从</div>更改为</table>,这将稍微改变您的javascript:
function checkA() {
document.getElementById('loan').style.display = 'none';
document.getElementById('assigned').style.display = 'table';
}
function checkL() {
document.getElementById('assigned').style.display = 'none';
document.getElementById('loan').style.display = 'table';
}发布于 2017-05-31 16:32:40
请注意,不能在表包装器中使用div元素。如果您希望使用div元素将CSS添加到表的一部分。最好向表头/行/数据添加一个ID,或者只为表的特定部分创建一个新表。
https://stackoverflow.com/questions/44287597
复制相似问题