[thelist] Passing params to PHP served paged in iFrame...

Richard Dyce dickiedyce at uk.com
Tue Apr 11 14:43:30 CDT 2006

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  


**** example client.html file as follows:
     <script type="text/javascript" src="calendar.js"></script>

**** calendar.js file as follows:
document.write('<iframe id="calendarFrame" src="server.php">');

function reloadCalendar(yearMonth) {
   var URL = 'server.php?yearmonth=' + yearMonth;
   return false;

****server.php file as follows:

   <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>

   <?php $ym = $_REQUEST['yearmonth']; echo "show calendar for $ym"; ?>


More information about the thelist mailing list