reference parameter question

Discussion in 'Javascript' started by Mitch Edelman, Feb 2, 2004.

  1. 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
     
    Mitch Edelman, Feb 2, 2004
    #1
    1. Advertising

  2. On 2 Feb 2004 15:56:09 -0500, Mitch Edelman <> wrote:

    [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

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
     
    Michael Winter, Feb 2, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    532
    Matteo
    Mar 29, 2007
  2. Stuart Redmann
    Replies:
    5
    Views:
    493
    Stuart Redmann
    Dec 14, 2007
  3. Replies:
    5
    Views:
    649
  4. Isti
    Replies:
    2
    Views:
    734
  5. Mister B
    Replies:
    8
    Views:
    568
    Nick Keighley
    Aug 26, 2010
Loading...

Share This Page