这是我的代码。请帮助我,因为我没有任何基本的Javascript编程。如果第一个下拉列表中的用户NOT SELECT OTHERS,则不会出现第二个元素和按钮。然后选择无法提交,因为按钮没有出现。如果用户从第一个下拉列表中选择OTHERS,则第二个元素和按钮将显示或可见。是什么造成的?
<html>
<head>
<title></title>
<script>
function checkchange() {
if (document.getElementById('favouritecolour').value == 'OTHERS') {
document.getElementById('other').style.display='block';
} else {
document.getElementById('other').style.display='none';
}
};
function check() {
if (document.getElementById('pets').value == 'OTHERS') {
document.getElementById('besides').style.display='block';
} else {
document.getElementById('besides').style.display='none';
}
};
</script>
</head>
<body>
<select id='favouritecolour' onChange='checkchange()'>
<option value='BLUE'>BLUE</option>
<option value='RED'>RED</option>
<option value='OTHERS'>OTHERS</option>
</select>
<div id='other' style="display: none">
<input type='text' placeholder="FILL IN"/><br/>
<select id='pets' onChange='check()'>
<option value='DOG'>DOG</option>
<option value='RABBIT'>RABBIT</option>
<option value='OTHERS'>OTHERS</option>
</select>
<div id='besides' style="display: none">
<input type='text' placeholder="FILL IN"/>
<input type="submit" name="SUBMIT" />
</div>
</body>
</html>