Loading ...
Sorry, an error occurred while loading the content.

addListener() and form submit event

Expand Messages
  • Sonny Savage
    I am looping over forms in my page, and adding submit listeners to them. This works great, except I can figure out how to tell which form was submitted once
    Message 1 of 4 , Mar 7, 2007
    • 0 Attachment
      I am looping over forms in my page, and adding "submit" listeners to them.  This works great, except I can figure out how to tell which form was submitted once I am in the event handler function.  If I use the getTarget() on the event, it returns the form object when a submit button is clicked, but doesn't when the form is submitted by pressing the [enter] key.  Is there a simpler way to do this that I'm overlooking?

      //Code Example (this is inside a loop)
      YAHOO.util.Event.addListener(aForms[i], "submit", submitHandler);
    • Sonny Savage
      Seriously... nobody knows?
      Message 2 of 4 , Mar 8, 2007
      • 0 Attachment
        Seriously... nobody knows?

        On 3/7/07, Sonny Savage <sonnysavage@...> wrote:
        I am looping over forms in my page, and adding "submit" listeners to them.  This works great, except I can figure out how to tell which form was submitted once I am in the event handler function.  If I use the getTarget() on the event, it returns the form object when a submit button is clicked, but doesn't when the form is submitted by pressing the [enter] key.  Is there a simpler way to do this that I'm overlooking?

        //Code Example (this is inside a loop)
        YAHOO.util.Event.addListener(aForms[i], "submit", submitHandler);

      • tssha
        ... form was ... getTarget() ... clicked, ... key. Is ... Could you not distinguish the event type? You should be able to discern between a click event and a
        Message 3 of 4 , Mar 8, 2007
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, "Sonny Savage"
          <sonnysavage@...> wrote:
          >
          > Seriously... nobody knows?
          >
          > On 3/7/07, Sonny Savage <sonnysavage@...> wrote:
          > >
          > > I am looping over forms in my page, and adding "submit" listeners to
          > > them. This works great, except I can figure out how to tell which
          form was
          > > submitted once I am in the event handler function. If I use the
          getTarget()
          > > on the event, it returns the form object when a submit button is
          clicked,
          > > but doesn't when the form is submitted by pressing the [enter]
          key. Is
          > > there a simpler way to do this that I'm overlooking?
          > >
          > > //Code Example (this is inside a loop)
          > > YAHOO.util.Event.addListener(aForms[i], "submit", submitHandler);

          Could you not distinguish the event type? You should be able to
          discern between a click event and a keypress event that triggered the
          submit event. If the "enter" key was pressed, traverse up the nodes
          until you reach the form.

          Regards,
          Thomas
        • Sonny Savage
          Thanks for the reply! It turns out that the event passed always has a type of submit. What I didn t know is that the form object was already available as
          Message 4 of 4 , Mar 11, 2007
          • 0 Attachment
            Thanks for the reply!  It turns out that the event passed always has a type of submit.  What I didn't know is that the form object was already available as "this".  I discovered it using a breakpoint in Firebug.  That's a relief, it was driving me nuts.

          Your message has been successfully submitted and would be delivered to recipients shortly.