Matt, in JavaScript, the forms sit within a collection below the document
root within the DOM.  You should be able to directly reference your forms
via index through JavaScript, using document.forms[0].submit(),
document.forms[1].submit(), etc.  HOWEVER, I would highly suggest switching
your forms to have different names, as noted in your second version with the
index included or something else uniquely identifying them, as maintaining
references to items within the DOM of the browser through index will be a
real hassle moving forward for page maintenance.  It is a much better
architectural approach to switch the names of your forms, but the above
should work.

Hope this helps,
Adam S. Grohs
Senior Front End Technologist
Scient, Inc.
[EMAIL PROTECTED]

----- Original Message -----
From: "Matt Read" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 16, 2002 1:54 PM
Subject: Javascript submit


> Hi, I've got a problem with submitting forms via javascript. I've got a
page
> with multiple forms created using <logic:iterate> I want submit these
forms
> using a link as opposed to a submit button. However the forms all have the
> same name so <html:link href="javascript: document.myForm.submit()"
doesn't
> work. It would appear that what I need is an "indexed" attribute on the
> html:form tag.
>
> This would mean that instead of rendering:
>
> <form name="myForm">...</form>
> <form name="myForm">...</form>
> <form name="myForm">...</form>
>
> I would get something like:
>
> <form name="myForm1">...</form>
> <form name="myForm2">...</form>
> <form name="myForm3">...</form>
>
> I could then construct the javascript to submit each form from the index,
> e.g.
>
> <html:form action="myAction">... <html:link page="<%= "javascript:
> document.myForm" + myIndex + ".submit()" %>"/></html:form>
>
> Can anyone comment on whether this would be the best way to do it? Is
there
> another way to easily refer to the correct form in javascript?
>
> I would appreciate any help.
> Thanks,
> Matt
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to