Multiple forms and this...

J

jodleren

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?
 
J

jodleren

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top