How to target HTML forms to an iframe..

liunx

Guest
Hi,<br />
I have a form which I intend to submit to a servlet. When the user clicks on the 'submit' button it activates an onClick method that opens a child page and creates an iframe to display the returned form in. <br />
<br />
The child page also gives the id of this new iframe back to the opener window which then sets the target of the form to be the new iframe.<br />
<br />
That is the idea but it is not targetting correctly and instead the servlet is opening a new IE window and displaying the result in it.<br />
<br />
Here is the code:<br />
The Parent window:<br />
<form id= "form" action="/servlet/viewerServlet"><br />
<input type="Button" onclick="openViewer()" value="Subscribe" /><br />
</form><br />
<br />
The Parents JavaScript file:<br />
function openViewer()<br />
{ if(viewer==null || viewer.closed==true)<br />
{ viewer = window.open("multiviewer.html");<br />
}<br />
else<br />
{ addPage();<br />
}<br />
}<br />
function addPage()<br />
{ /*This function in the child page<br />
creates the frame and returns its id*/ <br />
var frameId = viewer.createTab();<br />
//This gets the relevant form.<br />
var form = document.getElementById("form");<br />
form.target = frameId;<br />
form.submit();<br />
}<br />
<br />
<br />
Does anyone know how I can get the servlet to return to the relevant iframe like I want it to? I thought it might be a problem of ids versus names but I tried supplying a frame name instead and it had no effect.<br />
<br />
Any suggestions would be greatly appreciated thanks.<!--content-->Sorry I meant to add that I think the problem is the target is just being set to an id e.g."frame1" and the form does not understand that I am saying to go to the child page and THEN go into this iframe "frame1" within the child page.<br />
<br />
Sorry if this seems a bit confusing but I can't figure out how to direct the target reference correctly.<!--content-->
 
Back
Top