2011-06-16 30 views
0

下面是一個表單的工作示例。如果用戶在下拉菜單中選擇「其他」,我需要顯示其他文本字段。從屬選擇問題

不幸的是,我不能使用下面的例子,因爲它需要Mootools,但我使用Jquery。不想強制用戶只爲一個表單下載一個文件(Mootools)。

有沒有辦法如何做到這一點沒有Mootools?謝謝。

<form action='user_friends_manage.php' method='POST'> 
<table cellpadding='0' cellspacing='0'> 
<select name='friend_type' onChange="if(this.options[this.selectedIndex].value == 'other_friendtype') { $('other').style.display = 'block'; } else { $('other').style.display = 'none'; }"> 
<option></option> 
<option value='1'>Friend</option> 
<option value='2'>Family</option> 
<option value='other_friendtype'>Other</option></select> 
</td> 
<td class='form2' style='display: none;' id='other'>&nbsp;<input type='text' class='text' name='friend_type_other' maxlength='50' /></td> 
</tr></table></form> 

回答

0

嘗試: *話(THIS.VALUE == 'other_friendtype'){的document.getElementById( '其它')的style.display = '塊'。}中的onchage事件*

選擇控制。