Page 1 of 1

Load form results into iframe on different page.

Posted: Thu Aug 05, 2004 9:35 pm
by sell-traffic
Hi everyone,

I'm new here, referred by a friend. He recommended you guys, as no one else on other forums could help. I'm a fairly accomplished php programmer, and love joining forum communities, so I'm excited to find another one to join.

Here's my problem.

I have index.php which has a form on it. The form contains a drop down box, and a submit button. Clicking the submit button pulls a page from my other server. The page it pulls is just a form, on a white background, and needs to remain this way, as other members of my network access this page.

I need a way to pull that page into a seperate page called quote.php, so it can match the visual style of my site. My initial thought is to use an iframe on the quote.php page, but I can't figure out how to send the results to it.

I could do it if the iframe is on the same page as the form, just by using the target tag of the form. But on a seperate page? Must be a way to do it with javascript?

Thanks in advance,

Josh

Posted: Mon Aug 09, 2004 4:19 am
by CoderGoblin
If I get your requirement correct, it is possible using javascript. It would need something like the following...

in HTML

Code: Select all

<form target="target" method="method">
  <select  name="chooselist" onchange="javascript:openWin(this.value)">
    <option value=1>Option1</option>
    <option value=2>Option2</option>
  </select>
</form>
The javascript

Code: Select all

function openWin() &#123;
var new_win;
   new_win=window.open('source','title',
                        width=400,height=600,left=500,top=100,
                        resizable=yes,alwaysRaised=yes,scrollbars=yes,
                        status=no');
  if (new_win.location.href) &#123;
    new_win.focus();
  &#125;
&#125;
Three points to bear in mind.
1) No chance to test it, but should give you a starting point
2) Do you insist on users using javascript? If not you will need to rethink about opening a new window as this is not possible in php. As far as I know you would have to use frames.
3) I use an onChange event as I hate forcing users to click another button for a form submit when I don't have to.

Posted: Mon Aug 09, 2004 5:06 am
by CoderGoblin
Just reread your question. Previous answer opens a new window not uses an existing one...

In javascript you need to find the window you require using a command such as childwin=parent.framename. Using this you then need to get the iframe name and set it.
childwin.framename.location("src");

Again no time to try it out but if you need additional help please give more details (such as the actual frames being used.

I am sure you will get an answer.

Posted: Mon Aug 09, 2004 7:31 am
by JAM
You could dynamicly change the src value of the iframe tag:

Code: Select all

<iframe src ="/page.php?value=something"></iframe>
...then let page.php handle the $_GET data provided... Perhaps this can be applied to your solution aswell.

Posted: Mon Aug 09, 2004 9:52 am
by sell-traffic
Thanks I'll give it a shot, and post if it works or not.

Thanks,

Josh