<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - disabling and enabling text fields using javascript]]></title>
		<link>http://railsforum.com/viewtopic.php?id=38333</link>
		<description><![CDATA[The most recent posts in disabling and enabling text fields using javascript.]]></description>
		<lastBuildDate>Tue, 25 May 2010 10:14:34 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: disabling and enabling text fields using javascript]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=125195#p125195</link>
			<description><![CDATA[<p>Hi happs,</p><p>Well I have decided to change the entire outlook of what I am intended for&nbsp; doing.I have changed the way of taking the items from a drop down style to a radio_button manner.The new code is like this.</p><p>&lt;div id=&quot;trans_type&quot;&gt;<br />&lt;p&gt;<br />&lt;label for=&quot;&quot;&gt;Select Type Of Transaction&lt;/label&gt;<br />&lt;/p&gt;<br />Withdrawal<br />&lt;%= radio_button(&quot;userform&quot;, &quot;posting&quot;, &quot;Withdrawal&quot;) %&gt; <br />Deposit<br />&lt;%= radio_button(&quot;userform&quot;, &quot;posting&quot;, &quot;Deposit&quot;) %&gt; <br />Transfer<br />&lt;%= radio_button(&quot;userform&quot;, &quot;posting&quot;, &quot;Transfer&quot;) %&gt; <br />&lt;/div&gt;</p><p>I changed the drop down&nbsp; menu,s in a disabled mode as well.so when the page is loaded these four drop down will be in disabled mode.the new code is like this.</p><p>&lt;label for=&quot;&quot;&gt;Account Heads&lt;/label&gt; <br />&lt;%= select_tag(&quot;userform[head]&quot;,&quot;&lt;option&gt;------&lt;/option&gt;&quot;,:disabled =&gt; &quot;true&quot;+options_from_collection_for_select(@account,&quot;name&quot;,&quot;name&quot;)) %&gt;<br />&nbsp; <br />&lt;label for=&quot;&quot;&gt;Category&lt;/label&gt;<br />&lt;%= select_tag(&quot;userform[category]&quot;, &quot;&lt;option&gt;------&lt;/option&gt;&quot;,:disabled =&gt; &quot;true&quot; +options_from_collection_for_select(@category,&quot;Cname&quot;,&quot;Cname&quot;)) %&gt;</p><p>&lt;div id=&quot;from_acc&quot;&gt;<br />&lt;label for=&quot;&quot;&gt;From Accounts&lt;/label&gt;<br />&lt;%= select_tag(&quot;userform[faccounts]&quot;,&quot;&lt;option&gt;Select&lt;/option&gt;&quot;,:disabled =&gt; &quot;true&quot;+options_from_collection_for_select(@account,&quot;name&quot;,&quot;name&quot;))&nbsp; %&gt;</p><p>&lt;label for=&quot;&quot;&gt;To Accounts&lt;/label&gt;<br />&lt;%= select_tag(&quot;userform[toaccounts]&quot;,<br />&quot;&lt;option&gt;Select&lt;/option&gt;&quot;,:disabled =&gt; &quot;true&quot;+ options_from_collection_for_select(@account,&quot;name&quot;,&quot;name&quot;)) %&gt;<br />&lt;/div&gt;&nbsp; </p><p>If you connect this with earlier code you can understand.<br />so what&nbsp; my new way is that the drop down menus will be<br />enabled according to the selection of these radio_buttons.for eg:if <br />transfer is selected the fields such as &#039;faccounts&#039; and &#039;toaccounts&#039; will be enabled and all other menus will be in disabled mode.(well,i have a doubt that for these purpose radio_button will do the job or we want to use radio_button_tag?).I like to do this<br />with on-click event of javascript.</p><p>Any suggestions on this basis are welcome .</p><br /><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;thank you</p>]]></description>
			<author><![CDATA[dummy@example.com (jkruby)]]></author>
			<pubDate>Tue, 25 May 2010 10:14:34 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=125195#p125195</guid>
		</item>
		<item>
			<title><![CDATA[Re: disabling and enabling text fields using javascript]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=125191#p125191</link>
			<description><![CDATA[<p>Hi,</p><p>Did you change your html to wrap a div round the to and from sections like this</p><div class="codebox"><pre><code>&lt;div id=&quot;from_acc&quot;&gt;
    &lt;label for=&quot;&quot;&gt;From Accounts&lt;/label&gt;
    &lt;%= select_tag(&quot;userform[head]&quot;, &quot;&lt;option&gt;Select&lt;/option&gt;&quot;+     options_from_collection_for_select(@account, &quot;id&quot;, &quot;name&quot;)) %&gt;
&lt;/div&gt;
&lt;div id=&quot;to_acc&quot;&gt;   
    &lt;label for=&quot;&quot;&gt;To Accounts&lt;/label&gt;
    &lt;%= select_tag(&quot;userform[head]&quot;&quot;&lt;option&gt;Select&lt;/option&gt;&quot;+
options_from_collection_for_select(@account, &quot;id&quot;,&quot;name&quot;)) %&gt;
&lt;/div&gt;   </code></pre></div><p>This bit of code will grab each of those divs and switch them on/off as required</p><div class="codebox"><pre><code>jQuery(&#039;#from_acc, #to_acc&#039;).each(function()  &lt;-- for each matched element do the following (jQuery uses selectors similar to css)
    {
       var jthis = jQuery(this)  &lt;-- Create a jQuery object from the current element and store it
       if(jthis.attr(&#039;id&#039;) == &#039;from_acc&#039;)
       ........</code></pre></div><br /><p>I might have misunderstood what you meant though. If that is not doing what you want can you explain what should be happening</p>]]></description>
			<author><![CDATA[dummy@example.com (happs74)]]></author>
			<pubDate>Tue, 25 May 2010 08:49:24 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=125191#p125191</guid>
		</item>
		<item>
			<title><![CDATA[Re: disabling and enabling text fields using javascript]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=124041#p124041</link>
			<description><![CDATA[<p>Hi,</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;I am working on the basis of your suggestions over the last few days.I think you have concieved my query in a diffrent manner.when the &#039;transfer&#039; is being selected from the drop down the fields such as &#039;from accounts&#039; and &#039;to accounts&#039; should be displayed and the fields such as &#039;head&#039; and &#039;category&#039; should be in hidden form simultaneously.so i have confusion regarding this part of your suggestion because these all items come under the same drop down menu.</p><br /><p>{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type==&#039;Withdrawl&#039; || &#039;Transfer&#039; ? jthis.show() : jthis.hide();&nbsp; &lt;-- hide or show it as required<br />&nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp;else<br />&nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type==&#039;Deposit&#039; || &#039;Transfer&#039; ? jthis.show() : jthis.hide();<br />&nbsp; &nbsp; &nbsp; &nbsp;}</p><p>&nbsp; &nbsp; &nbsp; &nbsp;I would like to hear your say on this?I am an absolute beginner to jquery so if it is a mistake from my side please forgive me.</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Thank You.</p>]]></description>
			<author><![CDATA[dummy@example.com (jkruby)]]></author>
			<pubDate>Sat, 08 May 2010 17:50:12 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=124041#p124041</guid>
		</item>
		<item>
			<title><![CDATA[Re: disabling and enabling text fields using javascript]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=122580#p122580</link>
			<description><![CDATA[<p>If you wrapped the from/to accounts each in a div with an id of &#039;from_acc/to_acc&#039; respectively and give the select box an id of &#039;transaction_type&#039; then in jQuery you would do</p><div class="codebox"><pre><code>jQuery(document).ready(function()   &lt;-- Wait till document is loaded 
{
  jQuery(&#039;#transaction_type&quot;).change(function()  &lt;-- add an event handler to select input 
  {
    var type = jQuery(this).val();  &lt;--   Store the transaction type in a variable
    jQuery(&#039;#from_acc, #to_acc&#039;).each(function()  &lt;-- for each matched element do the following (jQuery uses selectors similar to css)
    {
       var jthis = jQuery(this)  &lt;-- Create a jQuery object from the current element and store it
       if(jthis.attr(&#039;id&#039;) == &#039;from_acc&#039;)   &lt;-- if we are dealing with the from_acc element then...
       {
          type==&#039;Withdrawl&#039; || &#039;Transfer&#039; ? jthis.show() : jthis.hide();  &lt;-- hide or show it as required
       }
       else
       {
          type==&#039;Deposit&#039; || &#039;Transfer&#039; ? jthis.show() : jthis.hide();
       }
    });
  });
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (happs74)]]></author>
			<pubDate>Mon, 12 Apr 2010 12:41:10 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=122580#p122580</guid>
		</item>
		<item>
			<title><![CDATA[disabling and enabling text fields using javascript]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=122568#p122568</link>
			<description><![CDATA[<p>Hi all,</p><p>A query connecting with java script here.</p><p>Firstly here is the code.</p><br /><p>&nbsp; &nbsp;&lt;label for=&quot;&quot;&gt;Transaction&lt;/label&gt;<br />&nbsp; &nbsp;&lt;%= select_tag(&quot;userform[transaction]&quot;,options_for_select([[&#039;select&#039;,&#039;select&#039;],[&#039;Withdrawal&#039;,&#039;Withdrawal&#039;],[&#039;Deposit&#039;,&#039;Deposit&#039;],[&#039;Transfer&#039;,&#039;Transfer&#039;]])) %&gt;&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;&lt;label for=&quot;&quot;&gt;Account Heads&lt;/label&gt; <br />&nbsp; &lt;%= select_tag(&quot;userform[head]&quot;, &quot;&lt;option&gt;Select&lt;/option&gt;&quot;+ options_from_collection_for_select(@account, &quot;id&quot;, &quot;name&quot;)) %&gt;<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;&lt;label for=&quot;&quot;&gt;Category&lt;/label&gt;<br />&nbsp; &nbsp;&lt;%= select_tag(&quot;userform[category]&quot;, &quot;&lt;option&gt;Select&lt;/option&gt;&quot; + options_from_collection_for_select(@category, &quot;id&quot;, &quot;Cname&quot;)) %&gt;</p><p>&nbsp; &nbsp;&lt;div id=&quot;transfer&quot;&gt;<br />&nbsp; &nbsp; &lt;label for=&quot;&quot;&gt;From Accounts&lt;/label&gt;<br />&nbsp; &nbsp; &lt;%= select_tag(&quot;userform[head]&quot;, &quot;&lt;option&gt;Select&lt;/option&gt;&quot;+&nbsp; &nbsp; &nbsp;options_from_collection_for_select(@account, &quot;id&quot;, &quot;name&quot;)) %&gt;<br />&nbsp; &nbsp;<br />&nbsp; &nbsp; &lt;label for=&quot;&quot;&gt;To Accounts&lt;/label&gt;<br />&nbsp; &nbsp; &lt;%= select_tag(&quot;userform[head]&quot;&quot;&lt;option&gt;Select&lt;/option&gt;&quot;+<br />options_from_collection_for_select(@account, &quot;id&quot;,&quot;name&quot;)) %&gt;<br />&lt;/div&gt;&nbsp; &nbsp;</p><p> Here what I needed is that when &#039;withdrawal &#039;and &#039;deposit&#039; is selected from the drop down transaction the fields &#039;from accounts&#039; and &#039;to accounts&#039; 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 &#039;transfer&#039; is being selected and simultaneously the fields &#039;account heads&#039; and &#039;category&#039; should be disabled.</p><p>Do anyone have any idea how to do this?Thanks in advance.</p>]]></description>
			<author><![CDATA[dummy@example.com (jkruby)]]></author>
			<pubDate>Mon, 12 Apr 2010 08:54:52 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=122568#p122568</guid>
		</item>
	</channel>
</rss>
