Hello,
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.

Recommended Answers

All 5 Replies

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

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"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>My first web page</title>
</head>
<div>
<frameset rows="25%,75%">
  <frame src="./instruction.php">
  <frame src="./displayForm.php?name=<?php echo $_GET[name]; ?>&url=<?php echo $_GET[url]; ?>">
</frameset>
</div>
</html>

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">
  <label>Name
  <input type="text" name="Name" id="Name" />
  </label>
  <br />
  <label>Email Address
  <input type="text" name="Email" id="Email" />
  </label>
  <p>
    <label>
    <input type="submit" name="post" id="post" value="Submit" />
    </label>
  </p>
</form>

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">
</form>

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.
Regards,
Sam Rudge

Thanks. its working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.