Entry
I have one link opening a new window, how do i get the 2nd link to prefill the form fields in windw?
Sep 23rd, 2002 06:29
Jean-Bernard Valentaten, Iain Waugh,
This shouldn't be a problem, since using the window object you can
access the document object of any popup you have generated, as long as
you have kept a reference to that popup in a variable:
var myWin = '';
function openWin()
{
myWin = window.open('someUrl', 'someTitle', 'the specs');
}
function prefillForm()
{
if (myWin != '')
{
if (myWin.document.myForm)
{
myWin.document.myForm.myElement1.value = 'some Value';
myWin.document.myForm.myElement2.value = 'some Value';
myWin.document.myForm.myElement3.value = 'some Value';
myWin.document.myForm.myElement4.value = 'some Value';
}
}
}
Now in the a-tags you'll write something like this:
<a href="javascript: openWin();">Open Popup</a>
<a href="javascript: prefillForm();">Fill it up</a>
That should work.
HTH,
Jean