Click to See Complete Forum and Search --> : How to target HTML forms to an iframe..


jovialjonny
06-10-2003, 11:58 AM
Hi,
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.

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.

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.

Here is the code:
The Parent window:
<form id= "form" action="/servlet/viewerServlet">
<input type="Button" onclick="openViewer()" value="Subscribe" />
</form>

The Parents JavaScript file:
function openViewer()
{ if(viewer==null || viewer.closed==true)
{ viewer = window.open("multiviewer.html");
}
else
{ addPage();
}
}
function addPage()
{ /*This function in the child page
creates the frame and returns its id*/
var frameId = viewer.createTab();
//This gets the relevant form.
var form = document.getElementById("form");
form.target = frameId;
form.submit();
}


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.

Any suggestions would be greatly appreciated thanks.

jovialjonny
06-10-2003, 12:01 PM
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.

Sorry if this seems a bit confusing but I can't figure out how to direct the target reference correctly.