Hi,

(FWIW: Descriptive subjects rather than "Help me with this" will tend
to be more useful.)

I think I must be misunderstanding the purpose of your script:  Labels
aren't submitted when you submit a form, focussed or otherwise.
Labels are a means of connecting descriptive text with form elements,
giving the browser useful information to work with (so that, for
instance, they can interpret a click on a checkbox's label to mean
that you want to change the value of the checkbox; not to mention a
wide variety of assistive technology uses -- screen readers, etc.).

If you can create a **very small, self-contained, but complete**
example of a page with a form that does what it is you don't want it
to do, we can probably help you figure out how to prevent it...

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Jan 18, 12:03 am, Colorblind <dust_...@yahoo.com> wrote:
> 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 <kan...@gmail.com> wrote:
>
> > On Jan 17, 1:18 pm, Colorblind <dust_...@yahoo.com> 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to