Thanks! I don't think I got the first 2 right yet, because only the
3rd worked for me, but I'm sure it's a matter of getting my parameters
straight. That syntax is beyond my Prototype experience already so I
still have to parse it (mentally).
The Prototype script that does the toggling sets the 'visible'
attribute of the given element, if I am not mistaken. From
prototype.js:
Element.Methods = {
visible: function(element) {
return $(element).style.display != 'none';
},
toggle: function(element) {
element = $(element);
Element[Element.visible(element) ? 'hide' : 'show'](element);
return element;
},
Based on stuff I have seen on the label element, such as at
http://www.w3schools.com/TAGS/tag_label.asp and in the JavaScript
Bible, 'label' really doesn't have many exposed properties, and they
aren't showing any base attributes such as the 'visible' that I was
looking for. (Along with 'id', 'name', etc.).
But then, my JS/DOM knowledge is pretty rusty. I'm still not sure why
labels have special status, i.e. no 'id' of their own, guess it's just
another old HTML quirk, eh?
Thanks a lot for your help.
-Kent
On Jun 4, 8:47 pm, kangax <[EMAIL PROTECTED]> wrote:
> Are you trying to toggle a label?
>
> $$('form#formId label')[0].toggle();
> $('formId').down('label').toggle();
> $$('label[for="firstNameId"]')[0].toggle();
> // etc.
>
> Which not-supported attributes are you talking about?
>
> - kangax
>
> On Jun 4, 5:05 pm, kentb <[EMAIL PROTECTED]> wrote:
>
> > Hi all -
> > This is a newbie question. Given a simple form such as
>
> > <form>
> > <label for="firstNameId">First Name</label>
> > <input id="firstNameId" name="firstName" type="text" value="">
> > </form>
>
> > we can use Element.toggle('firstNameId') to toggle visibility of the
> > input field, which is great.
>
> > Is it really true that this cannot work for the label field as well?
> > It looks to me like it's not possible because 'label' only supports 2
> > attributes in the DOM, and 'visible' is not one of them?? Can this
> > really be??
>
> > It just seems really silly not to support other basic attributes. Am
> > I missing something? Do I see this clearly? What workarounds are out
> > there for this?
>
> > Sorry if this is too simple - I searched around but didn't see
> > anything addressing this. I did notice in Firebug and in my JS that
> > the label fields have no id themselves...seems ridiculous. Maybe
> > there's a good reason?
>
> > Thanks a lot -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---