You could add your own attribute to a form tag, so that your javascript
could distinguish forms based on the value/presence of this attribute.

eg the following has 5 different forms, all with the same name and fields,
but I've added a new attribute 'mylabel':

<html>

<head>
<script>
function showForms() {
 var s='';
   for (var i=0;i<document.forms.length;i++) s+="Form label is
"+document.forms[i].mylabel+"\n";
 alert(s);
}
</script>
</head>

<body onLoad="showForms();">

<form action="action.do" mylabel="01">
<textarea name="YP01" cols="70" rows="3">
</textarea>
</form>

<form action="action.do" mylabel="02">
<textarea name="YP01" cols="70" rows="3">
</textarea>
</form>

<form action="action.do" mylabel="03">
<textarea name="YP01" cols="70" rows="3">
</textarea>
</form>

<form action="action.do" mylabel="04">
<textarea name="YP01" cols="70" rows="3">
</textarea>
</form>

<form action="action.do" mylabel="05">
<textarea name="YP01" cols="70" rows="3">
</textarea>
</form>


</body>
</html>

Regards,
John

[EMAIL PROTECTED]
Ph (09) 372-5010


|---------+---------------------------->
|         |           Jacob Weber      |
|         |           <[EMAIL PROTECTED]|
|         |           .com>            |
|         |           Sent by: news    |
|         |           <[EMAIL PROTECTED]|
|         |           rg>              |
|         |                            |
|         |                            |
|         |           15/08/2004 03:19 |
|         |           AM               |
|         |           Please respond to|
|         |           "Struts Users    |
|         |           Mailing List"    |
|         |                            |
|---------+---------------------------->
  
>--------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                          |
  |       To:       [EMAIL PROTECTED]                                                  
                     |
  |       cc:                                                                          
                          |
  |       Subject:  Specifying HTML form names                                         
                          |
  
>--------------------------------------------------------------------------------------------------------------|





I have a JSP with two forms, and they both need to go to the same
action. But Struts assumes that the "name" property of the HTML form
(e.g. <FORM NAME="MYFORM">) should be the same as the name of the
associated form bean. As a result, I can't use JavaScript to refer to
one of the forms, since they both have the same name.

Is this a situation where I need to write my own version of <html:form>?
Why does Struts make this assumption?

Things I've already considered:

- Using two different actions with different form beans. This doesn't
work, since the JSP needs to refer to the form bean by name (for
example, in <bean:write>). If I use two actions that return the same
JSP, they need to use the same form bean.

- Combining the two forms into one. This doesn't work in my situation,
since the forms need to submit different values for the same fields.

- Referring to the forms by number in my JavaScript (e.g.
document.forms[0]). This doesn't work, since there may be other forms on
the page, which would throw off the numbering.

Any ideas?
Thanks,
Jacob


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




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

Reply via email to