reference parameter question

M

Mitch Edelman

I am writing a validation function: what I want to do
when an error is detected is to open a second
window containing error messages.
The form being validated is rather long, and there
are several points in the code where I write the
messages. So, I would like to have a separate function
just to open the second window with an appropriate
title (something like "the following errors were
detected in your form").
(something labout like this:

function validate(this){
var headerWritten = false;
....

//when I trap an error (done in many places)

if (!headerWritten){
OpenSecondWindow(secondWindow, secondWindowDocument);
headerWritten=true;
}
secondWindowDocument.write('apporpriate error message');

My problem: secondWindow and secondWindowDocument seem to need
to be passed as references to this OpenSecondWindow
function - how to do this???????

Of course, if you know of an easier way to do this, I'd be
grateful if you'd pass that bit of knowledge along ...

Thanks in advance.

Mitch Edelman
 
M

Michael Winter

[snip]
if (!headerWritten){
OpenSecondWindow(secondWindow, secondWindowDocument);
headerWritten=true;
}
secondWindowDocument.write('apporpriate error message');

My problem: secondWindow and secondWindowDocument seem to need
to be passed as references to this OpenSecondWindow
function - how to do this???????

Of course, if you know of an easier way to do this, I'd be
grateful if you'd pass that bit of knowledge along ...

Return the reference. You don't seem to return anything from the function,
OpenSecondWindow, so return a reference to the window object.

var secondWindow = OpenSecondWindow();
var secondWindowDocument = secondWindow.document;

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top