Topic: disabling and enabling text fields using javascript
Hi all,
A query connecting with java script here.
Firstly here is the code.
<label for="">Transaction</label>
<%= select_tag("userform[transaction]",options_for_select([['select','select'],['Withdrawal','Withdrawal'],['Deposit','Deposit'],['Transfer','Transfer']])) %>
<label for="">Account Heads</label>
<%= select_tag("userform[head]", "<option>Select</option>"+ options_from_collection_for_select(@account, "id", "name")) %>
<label for="">Category</label>
<%= select_tag("userform[category]", "<option>Select</option>" + options_from_collection_for_select(@category, "id", "Cname")) %>
<div id="transfer">
<label for="">From Accounts</label>
<%= select_tag("userform[head]", "<option>Select</option>"+ options_from_collection_for_select(@account, "id", "name")) %>
<label for="">To Accounts</label>
<%= select_tag("userform[head]""<option>Select</option>"+
options_from_collection_for_select(@account, "id","name")) %>
</div>
Here what I needed is that when 'withdrawal 'and 'deposit' is selected from the drop down transaction the fields 'from accounts' and 'to accounts' should be in hidden style ie (these two fields have to be in hidden style when the page is being loaded) and these two fields have to be displayed only when 'transfer' is being selected and simultaneously the fields 'account heads' and 'category' should be disabled.
Do anyone have any idea how to do this?Thanks in advance.