misra.manisha@gmail.com wrote:
Quote:
Hi,
>
I am using frames (I know that its not a good practice, but I have to).
Each of these frames have separate form variables, all of which are
needed in the parent frame.
>
Now, the problem is that only one frame in the parent frame has a
submit button. Is there any way in which I can submit the forms of
other frames on click of the submit of this particular frame? I mean,
is there any way in which I can access the forms in JSPs of other
frames?
>
Thanks.
Sure. Simple example looks like:
<frameset cols="50%,50%">
<frame name="frame1" src="frame1.html"/>
<frameset rows="50%,50%">
<frame name="frame2" src="frame2.html"/>
<frame name="frame3" src="frame3.html"/>
</frameset>
</frameset>
Frame1 and Frame2 look like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<form name="form1" action="http://www.google.com/">
</form>
</body>
</html>
Frame3 has the same form but with a submit button and the javascript
needed to submit all three forms at once:
<html>
<head>
<script type="text/javascript">
function updateAll() {
if (window.parent) {
window.parent.frame1.document.forms['form1'].submit();
window.parent.frame2.document.forms['form1'].submit();
document.forms['form1'].submit();
return true;
}
else {
return false;
}
}
</script>
</head>
<body>
<form name="form1" action="http://www.google.com/" onsubmit="return
updateAll();">
<input type="submit" value="Update"/>
</form>
</body>
</html>
HTH