Why not create a custom tag that descends from 
org.apache.struts.taglib.html.FormTag
and adds a single extra field , nameSuffix?
It then overrides doStartTag so that the name of the form has the
nameSuffix appended to it.

We create similar tags that write Javascript method calls
and/or check session data before writing the tag HTML.

Custom tags are really the way to go. They help remove scriptlets from
JSPs and simplify complex tag combinations. 

Toby

-----Original Message-----
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 16, 2002 1:55 PM
To: [EMAIL PROTECTED]
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