tags:

views:

147

answers:

3

I have a php page, which using javascript, creates a popup window which contains another php page. the php page in the popup window is basically a form, and will use that value to insert into a database. Using the following function to load the php page in a popup:

phppopup('edit_status.php?cmd=EditStatusData')

function phppopup(page){
child1 = window.open (page, "Ebay Auctions", "height=600,width=600,status=yes,toolbar=no,menubar=no,location=no");
child1.document.close(); 
}

How can i pass a value from the calling page to the page in the popup?

I am trying at the moment:

echo "<p><a href=\"#\" onclick=\"updateByEdit('". $username ."', '". $subcat ."')\">Edit User Info</a>
<p><a href='#' onclick=\"makewindows2('edit_status.php?cmd=EditStatusData&pk=". $pk ."'); return false;\">Historie</a>;

Which generates the following html:

<a href="#" onclick="updateByEdit('trendsandbrands', 'fakeapproved')">Edit User Info</a>
</strong></strong></strong></strong></p><p><strong><strong><strong><strong><a href="#" onclick="phppopup('edit_status.php?cmd=EditStatusData&amp;pk='); return false;">Historie</a>

It works fine for updateByEdit, why not for phpopup?

$pk is just an integer, which display fine in the page it the window is called from.

A: 

Well, you're already doing it - the GET variable in edit_status.php will have one entry, with key='cmd' and value='EditStatusData'. Just pass as many parameters as you need (while being mindful that such data will be publicly viewable).

Visage
That's what I thought, but it is not working..., see revised answer
Joshxtothe4
A: 

Just add the arguments as part of the get request:

phppopup("index.php?var1=value1&var2=value2"); // Get

etc.

Alternatively, for passing it arguments when it is open already, use the handle that is returned (child1) and access that window's DOM via javascript.

child1.document.getElementById("myelement").innerHTML = "Hello World"; // Parent Child

If you have trouble with this, get the child window to trigger a callback in the parent window via window.opener when the child document has loaded, e.g.

window.opener.myCallback(requestedinfo); // Parent window callback function
Antony Carthy
I'm trying that, but it fails horribly
Joshxtothe4
Those methods will work, perhaps post evidence of trying this for us to inspect? I have used this before.
Antony Carthy
A: 

I noticed that the generated HTML contains a query string that has HTML entities ('& amp;') instead of their actual equivalents. Make sure that updateByEdit(...) isn't returning entities or the query string won't be printed correctly.

d3r1v3d