tags:

views:

181

answers:

3

I am using FrameSets to divide screen into two panes. The left pane displays links whereas the right pane displays the actual pages. I want to know how to handle the issue when an entry Form is opened on the right-pane and submitted.

When I submit a Form, the action is passed to another .php file, which saves the records into MySQL database and must return to the same entry Form on the right pane.

The problem is that after saving, it blanks the screen and I am worried that if it returns, it might display the Entry form on the whole screen instead of the right-pane.

Please assist me on how to handle this.

A: 

I'm not entirely clear about your situation but a few pointers:

  • You can refresh a neighboring frame after submit through Javascript if they come from the same domain.
  • You can submit from within a frame into the whole window (allowing for a full refresh) using target="_top".
  • I think you can submit into a neighboring frame by using target="framename".
Pekka
Actually, I want to direct the control back to the Entry Form and that too in the right pane.
RPK
If I remember correctly (it's been a long time since I've worked with frames) you should be able to do that by setting your form's target to the name of the right pane, and then redirecting to the form in your script.
Pekka
But I am not following how to use _target from another file. I am clearing further: (1) Form is submitted. (2) A .php file process the entries. (3) redirect back to the Form in the right pane. Now how to redirect to open the same form in the right pane. At present it is opening in the whole page.
RPK
Have you tried giving the right hand frame a name (`name='righthandframe'`) and giving the form `target=righthandframe`? I'm busy and can't test the scenario but it *should* work. My apologies if it doesn't. The trick is that the whole thing is submitted into the right hand frame *from the start*, because the php script doesn't care which frame it runs in. You then end up with the form using a simple `header()` redirect in php.
Pekka
Ya, my right pane name is "righty". I am not following how to use it with header redirect of php.
RPK
You can't switch frames with a header redirect. That's what the target is for.
Pekka
A: 

You can specify the "target" attribute for your form. It controls, in what frame your output will be displayed after processing the form submission.

But I would highly recommend not to use frames! It's better to give structure to your page with the correct HTML elements elements and format everything with CSS.

Techpriester
At present, I can't undo my approach. How to use _target from the other file to open the same form on the right pane?
RPK
+2  A: 

In your right pane, you have a form that sends a POST request to a php file. That request has a target right from the beginning, the place where the browser will collect the response of the server. If this target is your right pane, then the response of the php file (the new form) will be displayed in your right pane.

<frameset>
  <frame id="leftpane" src="leftpane.php"></frame>
  <frame id="rightpane" src="rightpane.php"></form>
</frame>

rightpane.php

...
<form action="rightpane.php" target="rightpane" method="post">
...
</form>
...
Alsciende
Do I need to use "header" to redirect from the second file?
RPK
Ok, got it. Apart from what you suggested, I added this line at the top of the .php file: <META http-equiv="refresh" content="2; URL=listing_entry.html">
RPK
Concerning a HTTP-Header Redirect, it doesn't work that way. Redirect tells the browser to request another url on reception (in the same frame). What you want to do is to tell the browser to put the received document in another frame (which is not possible easily).
Alsciende