I need to set the value of a hidden field in a popup. The code that created the popup is:

var a_id;
function Wait_W001(urlpop,id)
popupurl = urlpop;
a_id = id;
setTimeout('PopWidnow(popupurl)', 7000);

function PopWidnow(url_pop)
var PopWidth=500;
var PopHeight=460;
var PopLeft=10;
var PopTop=10;
var subpop; subpop=window.open(url_pop,'subpop','toolbar=no,status=no,menubar=no,location=no,directories=no,resizable=yes,scrollbars=no,width='+PopWidth+',height='+PopHeight+',top='+PopTop+',left='+PopLeft);

The timer for the popup is triggered by:
<BODY onLoad="Wait_W001('subpop.html',56789)" in the main window.

So, the popup is created and the contents of subpop.html are then written into it...

{Note: The hard-coded value passed to "id" in of Wait_W001(urlpop,id) will eventually be injected into the main page, most likely by using Perl or
PHP to generate the main page. For now, though, my problem is in the
popup window.}

I need to set the value for this hidden input:
<INPUT TYPE="hidden" NAME="aff_id" VALUE="">
in the form named "popform" in the popup window.

I wrote this code (and put it inside the BODY tag of the popup):

<script language=JavaScript type="Text/JavaScript">
var id;

to get the value of [var] a_id from the opening window using the window.opener method and use it to set the value of the aff_id form input field to the value accessed from the parent window.

Here's the opening FORM tag for reference:
<FORM METHOD="POST" NAME="popform" ACTION="bnbform11.cgi" ENCTYPE="x-www-form-urlencoded">

This just doesn't work. What am I doing wrong? Any help would be very much appreciated.