2011-06-16 27 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事件*

选择控制。