這是我的表單,如果選擇city2選項,我需要禁用textarea,如果選擇了其他選項,則啓用textarea。onchange disable textarea php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
var citySelect = document.getElementById('city'),
descriptionTextarea = document.getElementById('description');
citySelect.addEventListener('change', function() {
descriptionTextarea.disabled = citySelect.selectedIndex == 1;
}, false);
</script>
</head>
<body>
<form method="post" name="areaform" id="areaform">
<select name="city" id="city">
<option value="city1">city1</option>
<option value="city2">city2</option>
<option value="city3">city3</option>
</select><br />
<br />
<textarea name="description" id="description" cols="" rows="" style="width:150px; height:50px;"></textarea>
</form>
</body>
</html>
我該怎麼做?
請參閱我的更新問題。即使在Mozilla中它也不適用於我。我無法追蹤爲什麼? – designersvsoft 2012-03-17 10:42:45
@designersvsoft查看小提琴。它表明它正在工作,並且應該很容易適應你的代碼。 – alex 2012-03-17 10:43:16