作者drlai (蘇打)
看板Web_Design
標題Re: [問題] 下拉式選單的應用?
時間Tue Jun 13 10:59:20 2006
※ 引述《sueadolph (人..只剩下不信任)》之銘言:
: 請問這樣子的下拉式選單要怎麼設定?
: 1.甲
: 2.乙
: 3.丙
: 4.其它
: 當選"其它"的時候,右邊會自動出現一個可輸入的框框
以下是簡單的程式碼..依照需求去改吧:D
<html>
<head>
<script type=text/javascript language=javascript>
function showBar()
{
if( document.getElementById('list').value==4 )
document.getElementById('otherbar').style.visibility="visible";
else
document.getElementById('otherbar').style.visibility="hidden";
}
</script>
</head>
<body>
<form>
<select id=list onchange=showBar()>
<option value=1 selected>甲</option>
<option value=2>乙</option>
<option value=3>丙</option>
<option value=4>其他</option>
</select>
<div id=otherbar style="visibility:hidden"><input type=text></div>
</form>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.138.17.45
1F:推 sueadolph:謝謝~ 06/13 22:48
2F:推 litthe:奇怪..連這樣的程式碼,都會被IE的安全性攔下= = 06/14 15:18