Called on form submit, clear all labels so they don't accidentally get
submitted to the server
Something like that

On Jan 18, 1:33 am, kangax <[email protected]> wrote:
> On Jan 17, 1:18 pm, Colorblind <[email protected]> wrote:
>
> > Hy everyone,
>
> > I have the following script :
>
> > if (Object.isUndefined(Axent)) { var Axent = { } }
> > Axent.SelfLabeledInput = Class.create({
> >         initialize: function() {
> >                 var labelSelector = arguments[0] || 'label';
> >                 $$(labelSelector).findAll(function(l) {return
> > (l.readAttribute
> > ('for') !== null)}).each(function(l){
>
> Why not just - `$$('label[for]')`?
>
> >                     l.hide();
> >                         $(l.readAttribute('for'))._value =
> > l.innerHTML;
> >                         if ($(l.readAttribute('for')).value.empty())
> > {
> >                 $(l.readAttribute('for')).value = $(l.readAttribute
> > ('for'))._value
>
> Executing `$(l.readAttribute('for'))` more than once seems
> unnecessary. Why not save it in a variable?
>
> >             }
> >                         $(l.readAttribute('for')).observe
> > ('blur',function(e){if
> > (Event.element(e).value == '') Event.element(e).value = Event.element
> > (e)._value;});
> >                         $(l.readAttribute('for')).observe
> > ('focus',function(e){if
> > (Event.element(e).value == Event.element(e)._value) Event.element
> > (e).value = '';});
> >                 });
> >         }
>
> > });
>
> > I want to write a function from this script that when i press the
>
> You "want to write a function from this script". What does that mean?
>
> > submit on a form, if an input is focused, it hides/clears it, so it
> > doesn`t get submitted to the database. Work with the latest Prototype
>
> You can't really track "focused" elements using native DOM methods.
> Instead, you can observe all of the elements for focus/blur events and
> "mark" them as "focused" accordingly. You can then check which element
> is currently focused right before submitting a form.
>
> [...]
>
> --
> kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to