확인란이 선택되어 있으면 텍스트 상자가 활성화되어야합니다. 그렇지 않으면 텍스트 상자가 비활성화되어야합니다.체크 상자에서 텍스트 상자 사용 안함 및 사용 가능
이 코드가 작동하지 않는 이유를 모르십니까?
<script type="text/javascript">
function toggleTB(what){
if(what.checked){document.test.from_address.disabled=1}
else{document.test.from_address.disabled=0}}
</script>
<% form_for(@test,:name => "test") do |f| %>
<table>
<tr>
<td class="right upcase none">
<%= f.label 'text_enabled', "Enable",:class => "capitalize none" %>
<%= f.check_box :text_enabled,:onclick => "toggleTB(this)" %>
</td>
</tr>
<tr>
<td class="right upcase none">
<%= f.label 'from_address', "From Address",:class => "capitalize none" %>
</td>
<td>
<%= f.text_field 'from_address', :maxlength => 16 %>
</td>
</tr>
</table>
<% end %>
아이디어가 있으십니까?
방법했던 그 일? ... 내 생각은 레일처럼 텍스트 필드의 id는 형태로 ... 그래서 난 당신이'document.getElementById를 수행해야합니다 생각했다'test_from_address' 될 것이라고했다 ("test_from_address"). disabled =! what.checked;' – rubyprince
@rubyprince 감사합니다. 나는 갱신했다. –