faqts : Computers : Programming : Languages : PHP : Not Quite PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 19 people (89%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

hi, is it possible to have php in frame A use a variable defined in frame B? and if so, how? thanking you.

Mar 28th, 2008 17:43
ha mo, Sven Fuchs, k b,


At first, you don't "have php in a frame". A frame is on the client's 
browser, so you have html in a frame. Of course the html code might be 
produced by php, but this takes place on the server.

So you can't use a php-variable in a script called from frame A, that's 
been defined (server-side) in a php-script called from frame B this way.

What you can do is to define a javascript variable or hidden form field 
in the frame B's html, get it from javascript in frame A and call a php-
script from A.

Something like this:

Frame B has called a script, that return html-code including:

<script> var some_var = "xyz"; </script> or:
<input type="hidden" name="some_var" value="xyz">

In Frame A, you have something like this:

<script>
function call_php ()
{
    some_var = parent.frameb.some_var or:
    some_var = parent.frameb.document.forms[0].some_var.value;

    document.location.href = "my_php_script.php?some_var=" + some_var;
}
</script>

<a href="javascript:call_php()">checkthisout</a>

hth. :)

Sven Fuchs



http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com