Your example WILL always point to the first form, since you use the index of
0 (zero). You need to use 1 to point to the second form. This works fine
for me:
<html>
<head>
</head>
<script language="JavaScript" type="text/javascript">
function tellMe(){
alert("Form 1: " + document.forms[0].form2Text.value);
alert("Form 2: " + document.forms[1].form2Text.value);
}
</script>
<body>
<form action="foo" method="post" name="foo" id="foo">
<input type="text" name="form2Text" value="This is 1">
</form>
<form action="bar" method="post" name="bar" id="bar">
<input type="text" name="form2Text" value="This is 2">
</form>
<input type="button" name="myButton" value="Click It" onclick="tellMe();">
</body>
</html>
On 7/31/06, Parvat Singh Ranawat <[EMAIL PROTECTED]> wrote:
Hi all,
I'm attempting to create a JSP that is made up of two forms. Each
form needs a same form bean and is processed by a same
action. The catch is that the one form comes from Header (This will be
there for all the pages as part of left panel )
and second is coming from my jsp and problem occures while calling JAVA
SCRIPT
ie
1) if I use document. form[0] then this always points to the first form
(which is there in Header)
2) if I use document.formName
then there is ambiguity which form to call.
so how to work in this situation
Thanks
Shakti