Connecting Tech Pros Worldwide Forums | Help | Site Map

Posting Data Between Frames

Raffi
Guest
 
Posts: n/a
#1: Aug 18 '05
I'm developing an application where the main page has an iframe that
contains the form. The "Submit" button is located on the main page (not
the iframe). Is it possible to get the form data from the iframe when
the "Submit" button is pressed in the main browser page?

Thanks,
Raffi


Erwin Moller
Guest
 
Posts: n/a
#2: Aug 18 '05

re: Posting Data Between Frames


Raffi wrote:
[color=blue]
> I'm developing an application where the main page has an iframe that
> contains the form. The "Submit" button is located on the main page (not
> the iframe). Is it possible to get the form data from the iframe when
> the "Submit" button is pressed in the main browser page?
>
> Thanks,
> Raffi[/color]

Yes, easy enough with Javascript.
Without Javascript, things get a lot more complicated (and I will not
discuss them here.)

Try reposting your question in comp.lang.javascript for detailed
description.

The idea is:
- Add a function to the event pressing the submitbutton.
(eg make it a button, and add onClick, or use onSubmit)
- read all the values from the form
val1 = document.forms.myinnerframeform.firstname.value;
val2 = document.forms.myinnerframeform.street.value;
etc.

Now call a function in your other frame (mainpage)
parent.frames.mainwindow.getThis(val1,val2);

But it has nothing to do with PHP.

Regards,
Erwin Moller
Colin McKinnon
Guest
 
Posts: n/a
#3: Aug 18 '05

re: Posting Data Between Frames


Raffi wrote:
[color=blue]
> I'm developing an application where the main page has an iframe that
> contains the form. The "Submit" button is located on the main page (not
> the iframe). Is it possible to get the form data from the iframe when
> the "Submit" button is pressed in the main browser page?
>
> Thanks,
> Raffi[/color]

Yes - go ask the same question on a javascript group.

C.
Raffi
Guest
 
Posts: n/a
#4: Aug 23 '05

re: Posting Data Between Frames


Thanks for your suggestions. I ended up using CSS (the application only
allows access with MSIE 5+) and sidestepped the tedious cross-frame
scripting.

Here's the code for anyone interested:

<style type="text/css">
<div.scroll {
height: 100px;
width: 300px;
overflow: auto;
border: 2px solid #0000ff;
background-color: #ffffff;
padding: 8px;}
</style>
<html><body>
<h4>Paint Supply Order Form</h4>
<form action="index.php" method="post">
<div class="scroll">
Item:
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
<br><br>
Quantity:
<input name="quantity" type="text" />
<br><br>
Color:
<input name="color" type="text" />
<br><br>
Weight:
<input name="weight" type="text" />
<br><br>
Location:
<input name="location" type="text" />
</div>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>

Ramon
Guest
 
Posts: n/a
#5: Aug 23 '05

re: Posting Data Between Frames


All of the suggestions on this topic are silly. If I needed to pass data
between frames I would just store that data in $_SESSION. And... now you
better sit down for this... not only will you be able to access data in
different frames, you can also access the same data in DIFFERENT BROWSER
WINDOWS (concurrent).

*SHOCK HORROR*

Anyway hope that helps.

D


Raffi wrote:[color=blue]
> Thanks for your suggestions. I ended up using CSS (the application only
> allows access with MSIE 5+) and sidestepped the tedious cross-frame
> scripting.
>
> Here's the code for anyone interested:
>
> <style type="text/css">
> <div.scroll {
> height: 100px;
> width: 300px;
> overflow: auto;
> border: 2px solid #0000ff;
> background-color: #ffffff;
> padding: 8px;}
> </style>
> <html><body>
> <h4>Paint Supply Order Form</h4>
> <form action="index.php" method="post">
> <div class="scroll">
> Item:
> <select name="item">
> <option>Paint</option>
> <option>Brushes</option>
> <option>Erasers</option>
> </select>
> <br><br>
> Quantity:
> <input name="quantity" type="text" />
> <br><br>
> Color:
> <input name="color" type="text" />
> <br><br>
> Weight:
> <input name="weight" type="text" />
> <br><br>
> Location:
> <input name="location" type="text" />
> </div>
> <br><br>
> <input type="submit" name="submit" value="Submit">
> </form>
>[/color]
Closed Thread