I made sure to add disabled to my select.
<%= date_select 'note', 'assigned_on', { :order =>
[:day, :month, :year], :disabled => true } %>
This is generated html
<div id="assigned_on_wrap" class="assigned_on disable">
<label for="note_assigned_on">Assigned On</label>
<input id="assigned_on" type="checkbox" value="1"
onclick="assigned_on_toggle();" name="assigned_on"/>
<select id="note_assigned_on_3i" disabled="disabled"
name="note[assigned_on(3i)]"></select>
<select id="note_assigned_on_2i" disabled="disabled"
name="note[assigned_on(2i)]"></select>
<select id="note_assigned_on_1i" disabled="disabled"
name="note[assigned_on(1i)]"></select>
</div>
I made the changes as suggested.
function assigned_on_toggle()
{
if ( $('assigned_on').value == '0' )
{
$('assigned_on_wrap').className = 'assigned_on';
$$('div.assigned_on_wrap select').each(function(el){el.disabled
=
false;});
$('assigned_on').value = '1';
$('assigned_on').checked = 'checked';
}
else
{
$('assigned_on_wrap').className = 'assigned_on disable';
$$('div.assigned_on_wrap select').each(function(el){el.disabled
=
true;});
$('assigned_on').value = '0';
$('assigned_on').checked = '';
}
}
I receive no errors from firebug, the fields just stay disabled now.
On Mar 21, 7:19 pm, Tom Gregory <[EMAIL PROTECTED]> wrote:
> $$ returns an array, which doesn't have a disabled property (until
> you add it). You'll need to iterate through them, such as with each.
>
> $$('.someClass select').each(function(el){el.disabled = true;});
>
> TAG
>
> On Mar 21, 2007, at 5:06 PM, OmenKing wrote:
>
>
>
> > I have a toggle for enabling and disabling a select field in my form.
>
> > This is how I want it to work.
> > [img]http://img260.imageshack.us/img260/8167/
> > disablefieldsassignedonrt6.gif[/img]
>
> > I can disable the select fields by selecting each one
> > application.js
> > [code=]function assigned_on_toggle()
> > {
> > if ( $('assigned_on').value == '0' )
> > {
> > $('assigned_on_wrap').className = 'assigned_on';
> > $('note_assigned_on_3i').disabled = '';
> > $('assigned_on').value = '1';
> > $('assigned_on').checked = 'checked';
> > }
> > else
> > {
> > $('assigned_on_wrap').className = 'assigned_on disable';
> > $('note_assigned_on_3i').disabled = 'disabled';
> > $('assigned_on').value = '0';
> > $('assigned_on').checked = '';
> > }
> > }[/code]
> > This works however id have to $() every select field.
> > When I attempt to select all as such:
>
> > [code=]$('assigned_on_wrap, 'select').disabled = 'disabled ';[/code]
> > or
> > [code=]$$('div.assigned_on_wrap select').disabled = 'disabled ';[/
> > code]
> > It has no affect on to the fields, they just stay enabled.
> > Any suggestions?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---