0
A
回答
0
假设您使用的是具有原型作为js库的旧版rails。
在选择列表中的onchange事件添加JavaScript函数来显示包含文本框格(假设你显示选择列表中的值5在文本框中):
<select id="select_item" name="select_item" onchange="display_date_range(this);">
... where 5 is the value of the option that needs to show text box
</select>
function display_date_range(list) {
if(list.options[list.selectedIndex].value == 5) {
$("text_div").show();
}
else {
$("text_div").hide();
}
}
<div id="text_div"><input type="text" value="Hooraaahhh..." /></div>
的哪个版本ROR?如果是3.0.x,那么你应该升级到3.1并使用jQuery,因为它成为默认的JS引擎。 (请参阅[这里](http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate)) – 2011-05-26 20:57:02
我使用旧版本2.3.x – user659068 2011-05-27 14:24:56