I did consider your first suggestion but there's no guarantee that there
won't be other forms on the same page which would put the numbering out.

Re your 2nd suggestion, what I'm really looking for is a way to do that
within a struts <logic:iterate> tag without rebuilding the struts source to
add an "indexed" attribute. I think a custom taglib as suggested by Toby
Steel is probably the easiest way to do it.

Thanks all,
Matt.

-----Original Message-----
From: Adam Grohs [mailto:[EMAIL PROTECTED]]
Sent: 17 May 2002 12:23
To: Struts Users Mailing List
Subject: Re: Javascript submit


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