I have a page consisting of two frames. The top frame holds instructions, the bottom frame holds a form. I need the top frame to disappear after the form is submitted. Could someone kindly tell me how I can do this?

Note: The frames are parts of the requirements. I wouldn't use them if I didn't have to.

8 Years
Discussion Span
Last Post by ryy705

You can specify parent='_top' with a link, that will open the page, replacing the current frames.

Please elaborate. I was always told that frames are evil, so I never used them before. I googled parent='_top' and its my understanding that it has to be placed inside an anchor tag. But I want a new page to open (without frames) when a form is submitted. How can I do this? Is there a way to use parent='_top' in the action attribute of a form?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<title>My first web page</title>
<frameset rows="25%,75%">
  <frame src="./instruction.php">
  <frame src="./displayForm.php?name=<?php echo $_GET[name]; ?>&url=<?php echo $_GET[url]; ?>">

When you post your form you need to tell it to post the form to the frame called _top, the frame _top is always the main browser window E.G. everything displayed in the browser.
You need to add a tag to your <form> tag telling it the frame:

<form action="/post.php" method="post" name="Form" target="_top">

So your complete form would look something like this:

<form action="/post.php" method="post" name="Form" target="_top">
  <input type="text" name="Name" id="Name" />
  <br />
  <label>Email Address
  <input type="text" name="Email" id="Email" />
    <input type="submit" name="post" id="post" value="Submit" />

You can also use the target= tag to specify a Frame or IFrame name, if you enter the ID of the frame then the form will change the URL of the frame and not the whole page E.G.

<iframe id="Frame1" width="100px" height="100px" name="Frame1" src="Page.html" />
<form action="/post.php" method="post" name="Form" target="Frame1">

and your form would post to the frame called Frame1 and the main URL would stay the same.

Hope this helps, if you have any more probs then reply to this and I will put an example on my site.
Sam Rudge

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.