Passing params to PHP served paged in iFrame...
| From: | Richard Dyce | Date: | Tue, 11 Apr 2006 18:58:26 +0000 |
| Subject: | Passing params to PHP served paged in iFrame... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-233789@lists.php.net to get a copy of this message | ||
Dear all,
Not so simple question. Here's what I'm trying to do.
I want to be able to provide a simple script tag pair so that my client's can cut and paste it into their site. This is to try and to make it as simple as posisble for them ;-) The script is then meant to write an iFrame into the document, using the served PHP file for the source. So far, so good. Now for the tricky part.
I want the PHP file to include a pop-up menu which calls a script in the calendar.js file, which in turn reloads (using replace so that the back button doesn't break) the served page, but with an updated parameter - essentially the new year and month to display.
Here are the bare bones of my not-quite-functioning solution. (I'm using Firefox - once I get it working I realise I'll need to tweak how I get the object to do the replace on, and indeed the replace function itself for IE 5 etc...)
The alert is working (so the parameter is being passed), but the reload isn't. What am I doing wrong?
Hope some passing geniuses out there can help/have cracked this one before.
R
**** example client.html file as follows:
--------
<html>
<head>
<title>Client</title></head> <body>
<h3>Calendar</h3>
<script type="text/javascript" src="calendar.js"></script>
</body>
</html>
-------
**** calendar.js file as follows:
--------
document.write('<iframe id="calendarFrame" src="server.php">');
document.write('</iframe>');
function reloadCalendar(yearMonth) {
alert(yearMonth);
var URL = 'server.php?yearmonth=' + yearMonth;
document.getElementById('calendarFrame').location.replace(URL);
return false;
}
---------
****server.php file as follows:
---------
<html>
<head>
<title>Server</title></head> <body> <form name="emailForm" id="emailForm" action="server.php"> <select name="yearmonth" onchange="top.reloadCalendar(this.value);">
<option value="2006-05">May 2006</option>
<option value="2006-06">Jun 2006</option>
<option value="2006-07">Jul 2006</option>
</select
<?php $ym = $_REQUEST['yearmonth']; echo "show calendar for $ym"; ?>
</body>
</html>
---------