# To Enable a disabled text\_field onclick of radio button?

**URL:** <https://www.ruby-forum.com/t/to-enable-a-disabled-text-field-onclick-of-radio-button/119407>\
**Category:** Rails\
**Created:** [November 6, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/to-enable-a-disabled-text-field-onclick-of-radio-button/119407 "2007-11-06T19:59:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [November 6, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/to-enable-a-disabled-text-field-onclick-of-radio-button/119407/1 "2007-11-06T19:59:26Z")

</div>

Hi,

I have 3 radio buttons, with 1st checked. If the 3rd radio button is  
clicked, i want to enable the text\_field.

Anything wrong in the code below? It doesn’t work ☹

\<%= radio\_button :profile, :nick\_name, “passport\_style”, :checked =\>  
“checked”, :onclick =\> “$(‘other\_text’).disable();” %\> \<%=  
@profile.first\_name + " " + @profile.last\_name %\>

\<%= radio\_button :profile, :nick\_name, “school\_style”, :onclick =\>  
“$(‘other\_text’).disable();” %\> \<%= @profile.first\_name + " " +  
@profile.last\_name[0…0] %\>

\<%= radio\_button :profile, :nick\_name, “user\_own\_style” ,  
:onclick =\> “$(‘other\_text’).enable();” %\>

\<%= text\_field ‘user\_choice’, ‘user\_choice’,  
:disabled =\> true %\>

Regards,  
Sandeep G

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [November 6, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/to-enable-a-disabled-text-field-onclick-of-radio-button/119407/2 "2007-11-06T20:19:54Z")

</div>

The problem is that your text field is not called “other\_text”, your  
span is. You need to change your code to $(‘user\_choice’) and this  
should work.

-Bill

Sandeep G. wrote:

> @profile.first\_name + " " + @profile.last\_name %\>   
>   
> :disabled =\> true %\>
> 
> Regards,  
> Sandeep G

–  
Sincerely,

William P.
