After you’ve inherited a crappy and poorly programmed website from someone else, that was done by a ‘lousy programmer’, sure enough the site owner will ask for ‘stuff’ to be done. Here we go!
“When I open a summary of my clients I need a checkbox beside their information. Then when I’ve checked all the clients I’m interested in I want to be able to send a batch email to them.”
So I need the child page ( aka pop-up window ) to ‘read’ the checkboxes left behind on the parent page that are ‘on’*. Then I need to invoke an ‘onLoad’ process to write the values of those client IDs into the form used by the child page using client side scripting. Piece of cake.
for( i = 0 ; i < window.opener.document.deleteform.elements[‘mdelete’].length; ++i )
if ( window.opener.document.deleteform.elements[‘mdelete’][i].checked==true )
document.write(“<input type=\”hidden\” name=\”mdelete\” value=\”” + window.opener.document.deleteform.elements[‘mdelete’][i].value + “\” />”);
Ok. Got that down. Now you discover that the ‘lousy programmer’ before you has used PHP SESSION variables to pass a SQL string along to pull the client list. Shouldn’t be a problem, right? Nope. window.opener is a wonderful little piece of code that lets you relate between parent and child pages but doesn’t allow SESSION variables pass.
Someone else has fallen on this sword before. Dare I say ‘lucky me’?
window.open( ‘customer_batch_email.php’ , ‘bEmail’ , ‘height=500,width=900,scrollbars=1’ );
Turning window.open into function such as the one above will allow SESSION variables to persist. Well, at least until the next user agent upgrade. Maybe I’ll be selling tooth paste at the demo kiosk of Costco by then. I left myself lots of clues and ‘in-script’ notes because sure as Shawn will show up for a free meal this will fail: next week, next year?
Thanks for listening. Anyone want my job?
Radar Hill Director of Product Development and Lead Programmer
*This is the useful part. You might need to detect state of HTML form elements just as I describe. Or, you may live a happy uneventful life where you’re never cursed with this.