Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

complex form target 2

Status
Not open for further replies.

peacecodotnet

Programmer
May 17, 2004
123
US
i want to have a form targeted to a certain frame in a certain window. for example, i will use javascript to open a window like this:

Code:
window.open('thewindow.php','thewindow','toolbar=no,status=no,width=500,height=320');

in that window, there will be an iframe named "theiframe". how do i get a form in a seperate window to execute it's action in that iframe?

Peace out,
Peace Co.
 
So you have a parent window (let's call it index.html) and a window it opens with the window.open(...) command (let's call it child.html).

In child.html, you have a FORM with an ACTION and also an IFRAME.

You want to submit the FORM in child.html, but you want the ACTION to carry out in IFRAME.

Is that what you are saying?

--Dave
 
In your main window, let's say you open a new window like this:

Code:
var the_win = window.open('somewindow.html', 'win', '');

The window you just opened, somewindow.html, has an iframe in it. Now, what you want to do, also from the main (original) window, is load an iframe in the new popup window with a page. You'd do so like this (adding onto my original line of code):

Code:
var the_win = window.open('somewindow.html', 'win', '');
the_win.document.getElementById('iframeid').src = 'coolpage.html';

And, obviously, you'd need to give that iframe an id of 'iframeid'.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
I think you misunderstood.

Lets say I have the page index.html open. index.html looks like this:

Code:
<html>
<head>
<script type="text/javascript">
window.open('otherwindow1.html', 'otherwindow');
</script>
<body>
<form action="otherwindow2.html" target="otherwindow">
<input type="submit" value="go to otherwindow2"></input>
</form>
</body>
</html>

See how the form in index.html will open otherwindow2.html in the 'otherwindow' window (which originally contained otherwindow1.html)? Now, here is the source of otherwindow1.html:

Code:
<html>
<body>
<iframe src="somerandompage.html" name="MeIframe"></iframe>
<p>When you go back to index.html and click the button, that iframe will load otherwindow2.html!
</body>
</html>

Ok. Let's break this down. With the above code, when you go to index.html, a window by the name of 'otherwindow' will open. Inside of the 'otherwindow' window, is otherwindow1.html.

When you click the button in index.html, the 'otherwindow' window will change to otherwindow2.html, because the target of the form is 'otherwindow'.

BUT

Did you notice the random iframe in otherwindow1.html? Well, what I want is that INSTEAD OF the entire window of 'otherwindow' changing to otherwindow2.html, ONLY THE IFRAME INSIDE OF 'OTHERWINDOW' changes to otherwindow2.html

Do you see what I mean? If anyone can figure this out, I will find a way to thank you greatly....I really need this.

Peace out,
Peace Co.
 
I just gave you that solution.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
no you didnt. first of all your explaination was unclear. second of all, i want ONLY the iframe in the NEWLY OPENED WINDOW to change AS A RESULT OF THE FORM ON THE OLD WINDOW BEING SUBMITED

Peace out,
Peace Co.
 
The solution I provided should get you started in the right direction. The code is there to make it work. USING CAPITAL LETTERS TO EXPRESS YOUR FRUSTRATION WILL NOT GET YOU ANYWHERE HERE.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
I'm sorry if the capitol letters seemed harsh--I wanted to emphasize those points, not show frusteration. And I hate how italics looks with this font so I used capitols instead.

Also, I already knew everything in your explaination...but I need to know how to make it work they way I need it to instead of that way--which is why I came to these forums. However, thank you for your efforts and I understand your confusion.

Peace out,
Peace Co.
 
There's really only one other suggestion I can come up with, and that's using JavaScript to a) load the iframe with a file and then b) pass the values in the form to the iframe's page. I'm not aware of any direct way to make an iframe on another page the target of a form.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top