Click to See Complete Forum and Search --> : FORM & PopUp work together


The Anime King
01-18-2004, 03:57 PM
On my site, you can fill in a form to register.
Then, a popup comes up with a list of avatars you can choose from.
If you click on one, i want the URL for that avatar to be put in the avatar-textarea in the form on the main page.
I've tried some things, but i can't target the avatar-textarea, even though i named it with NAME=.
Does anyone know the code for this? Please help me.
Greetzzz tAK

pnaj
01-18-2004, 04:34 PM
Show us your form that contains the avatar-text and also the bit of javascript that pop up the avatar window ... it'd be easier if we see that first.

The Anime King
01-19-2004, 01:53 PM
You can find the form here (http://members.lycos.nl/rpgcontestdb/site.php?id=admin/login/newdatabase.php&h=a)

If you click on Avatar Checker, you'll get a popup full of avatars. If you click on the name of the avatar, i'd like it to be filled into the form.
As you can see, i managed to get the url in an iframe on the bottom of the page with
<a href="javascript:document.write('<?php echo $url; ?>')" target=iframe> in the iframe.

Greetzzz tAK

pnaj
01-19-2004, 03:27 PM
Sorry, but I can't link to your page at the moment.

First time, I just got a page with the lycos banner and nothing else. Second time, just froze up.

Do you use javascript to actually pop up the window, or is just a target="_blank"?

If you're using js, then the call should be of the form:

var w = window.open(...);

My way to deal with this sort of thing is to do the following:
All 'setter' functions for the main window (as in your case) should be put in the head of the main window.
That way, you can call the functions bt referring to the 'top' attribute of ANY window you are calling from.

Suppose the name of your form is myForm and your text box is myText ... in the head of the main window, put the following between script tags:

function setMyText(str){
window.document.forms.myForm.myText.value = str;
}

Then from any window (including the main window), you call the function ...

window.top.setMyText('Hello, world');

-------------------
Hope that helps!
P.

The Anime King
01-20-2004, 01:52 PM
Hey again, thanx for the code, but it doesn't work yet :(
I know a little bit of javascript, but i know PHP, so i kinda understand about the code.
Still, i can't figure out what's wrong. When i click on the url, i get the message (translated from dutch): "This object does not support the property or method".
I added your code, but not the
var w= etc , because the popup needs to be opened with a hyperlink. Else, the popup may be killed by the user before being viewed.
Please help me a last time, cause i'm almost there.
Greetzzz tAK

The Anime King
01-20-2004, 02:03 PM
I made an example page on:
http://members.lycos.nl/rpgcontestdb/test.html

Paul Jr
01-20-2004, 02:22 PM
Khalid has an example of something like this here. (http://www.webapplikations.com/pages/html_js/window/ParentWinInteractionWithChildWin.html)

The Anime King
01-20-2004, 03:44 PM
That is exactly what i mean, but, i want the form in the parent window, and the options in the child window. Is that possible too?

Paul Jr
01-20-2004, 08:11 PM
It most certainly is. I attempted to throw something together, and I thought I got it down-pat, but when I put it in my server's root folder, and accessed it via my domain name, IT DIDN'T WORK! ARGH! My limited JS knowledge... GRRR!

Anyhoo, it's located here (http://mysteriously.no-ip.com/research/index.html).
And I'll .zip it for the hell of it.


***EDIT***
Scratch that. It works -- but only for IE. :( :confused:

Paul Jr
01-20-2004, 09:41 PM
WOO! Big thanks to fredmv! There is now a fully working example located here (http://mysteriously.no-ip.com/research/index.html.).
And I'll zip it for ya, too. Lemme know if that works. :)

The Anime King
01-21-2004, 11:48 AM
Thanx for the code, it worked perfectly on my computer. But once uploaded it doesn't respond anymore...
Here's an example:
http://members.lycos.nl/rpgcontestdb/
it's your file, i haven't edit this version. Still, it doesn't work :(
I guess it has something to do with lycos having some codes too, so form[0][0] isn't my form, but some of lycos. How can i rename that?
btw it's the first file that worked so far, so where on the right road :)

Greetzzz tAK

Paul Jr
01-21-2004, 07:08 PM
The document.forms[0][0] part shouldn't be the problem, since that points to the first field of the first form on the page. And there aren't any other forms on the page. The only thing I can think of is it might have something to do with the frames, but I'm not sure :(.