p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   Passing form values from 1 frame to another. (http://p2p.wrox.com/showthread.php?t=8408)

edkeyte January 21st, 2004 12:05 PM

Passing form values from 1 frame to another.
I have found out a way to pass forms from one frame to another but with the script I found, I can only pass one form field. I would like to pass 3 or more.

Here is a demo of what I mean:


As you can see by the demo, Only the email gets added to all field but I would like to add Email in the email field, Name in the name filed, and user name in the user name field of the form on the left, from the right.

joefawcett January 21st, 2004 12:41 PM

I would change the passText function to:

function passText(Name, Value)
  top.frames['right'].document.yourform[Name].value = Value;

then change your button to:

<INPUT onclick="parent.passAll(this.form);" type=button value=Add!>
and finally add the passAll function to the page with passText function:

function passAll(Form)
  passText("email", Form.user.value);
  passText("teacher", Form.user1.value);
  passText("user", Form.user2.value);

Note I renamed the textbox called 'name' to 'teacher'. This is because the expression 'yourform.name' is ambiguous, does it mean the name of the form or the element called 'name'? This can cause problems.



edkeyte January 21st, 2004 01:02 PM

Thank you so much for that very fast reply Joe.

Best regards Edward.

al February 2nd, 2004 11:53 AM

is "top.frames['right'].document" be browser specific ?

joefawcett February 2nd, 2004 12:33 PM

i believe it's standard, isn't it working on your browser?
If not it could be because the document in quetion is not in the same domain, i.e. from the same server and usaing same protocol (both HTTP rather than one HTTP and the other HTTPS for example) as the frame where the code is. This would be a security violation so is not allowed.




All times are GMT -4. The time now is 06:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.