Multiple forms and this...

Discussion in 'Javascript' started by jodleren, Mar 6, 2008.

  1. jodleren

    jodleren Guest

    Hi!

    I have a page, where I need to track which form is being submitted.

    My code is as follows:

    .....echo "</form>"...
    echo "<form method=\"post\" name=\"dm_settings2b\" action=
    \"$sLinkSelf\"
    onsubmit=\"if(this.submitted) return false; else
    { this.submitted = true; DisableSubmits(this); return true; }\">";
    [I have 3 forms A, B and C for now]

    Next, JS:

    function DisableSubmits(frm)
    {
    var i, j;
    for(i = 0; i < document.forms.length; i++)
    {
    for(j = 0; j < document.forms.elements.length; j++)
    {
    if((document.forms.reply.value=="none") &&
    (document.forms.elements[j].type.toLowerCase() ==
    'submit'))
    {

    document.forms.reply.value=document.forms.elements[j].name;
    alert(document.forms.elements[j].name);
    }
    if((document.forms.elements[j].type.toLowerCase() ==
    'submit') ||
    (document.forms.elements[j].type.toLowerCase() ==
    'button'))
    document.forms.elements[j].disabled=true;
    }
    }

    problems: the for(i = 0; i < document.forms.length; i++) can
    only see one form at all times. Why? I have 3!
    Then again, it does not matter which form I submit, frm.name above is
    always the a-form....

    What do I do wrong here?
     
    jodleren, Mar 6, 2008
    #1
    1. Advertising

  2. jodleren

    jodleren Guest

    On Mar 6, 10:08 pm, jodleren <> wrote:
    > Hi!
    >
    > I have a page, where I need to track which form is being submitted.
    >
    > My code is as follows:
    >
    > ....echo "</form>"...
    >       echo "<form method=\"post\" name=\"dm_settings2b\" action=
    > \"$sLinkSelf\"
    >         onsubmit=\"if(this.submitted) return false; else
    > { this.submitted = true; DisableSubmits(this); return true; }\">";
    > [I have 3 forms A, B and C for now]
    >
    > What do I do wrong here?


    40cm - form is not spelled from :)

    Sorry guys
     
    jodleren, Mar 6, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    2
    Views:
    1,527
    Tommy
    Feb 13, 2004
  2. doug
    Replies:
    6
    Views:
    4,641
    Andrew Thompson
    Jan 27, 2004
  3. Keltex
    Replies:
    1
    Views:
    419
    Dominick Baier [DevelopMentor]
    Jan 24, 2006
  4. Eric
    Replies:
    2
    Views:
    595
  5. sandyde2
    Replies:
    2
    Views:
    189
    sandyde2
    Oct 2, 2003
Loading...

Share This Page