Not sure if this is your issue, but you should try:
('contact_phonenumber').attr('disabled', $('contact_can_call').checked);
In general with jQuery I lean towards using attr instead of accessing
things directly. Although the .checked/value/etc of input elements is
an exception.
Best,
Erik
On Sat, Sep 25, 2010 at 11:57 AM, joshua <[email protected]> wrote:
> Hi,
>
> I am trying to figure out the syntax to enable text field based on
> checkbox selection. Your help is greatly appreciated.
>
> What is wrong with the following definition?
>
> <% form_for(@contact) do |f| %>
> ...
> <p>
> <%= f.label :can_call %><br />
> <%= f.check_box :can_call, :onclick => "$
> ('contact_phonenumber').disabled = $
> ('contact_can_call').checked;", :onchange => "$
> ('contact_phonenumber').disabled = $('contact_can_call').checked;" %>
> </p>
> <p>
> <%= f.label :phonenumber %><br />
> <%= f.text_field :phonenumber, :size => 80, :maxlength =>
> 20, :disabled => "$('contact_can_call').checked?false:true;" %>
> </p>
> ...
> <% end %>
>
> Thanks,
>
> Josh
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby