reference parameter question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mitch Edelman

    reference parameter question


    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 ){
    OpenSecondWindo w(secondWindow, secondWindowDoc ument);
    headerWritten=t rue;
    }
    secondWindowDoc ument.write('ap porpriate error message');

    My problem: secondWindow and secondWindowDoc ument seem to need
    to be passed as references to this OpenSecondWindo w
    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
  • Michael Winter

    #2
    Re: reference parameter question

    On 2 Feb 2004 15:56:09 -0500, Mitch Edelman <edelman@umbc.e du> wrote:

    [snip]
    [color=blue]
    > if (!headerWritten ){
    > OpenSecondWindo w(secondWindow, secondWindowDoc ument);
    > headerWritten=t rue;
    > }
    > secondWindowDoc ument.write('ap porpriate error message');
    >
    > My problem: secondWindow and secondWindowDoc ument seem to need
    > to be passed as references to this OpenSecondWindo w
    > 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 ...[/color]

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

    var secondWindow = OpenSecondWindo w();
    var secondWindowDoc ument = secondWindow.do cument;

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • Dennis M. Marks

      #3
      Re: reference parameter question

      I have read the following message from edelman@umbc.ed u (Mitch Edelman)
      and have decided to lend my vast knowledge.

      The writer said:[color=blue]
      > 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 ){
      > OpenSecondWindo w(secondWindow, secondWindowDoc ument);
      > headerWritten=t rue;
      > }
      > secondWindowDoc ument.write('ap porpriate error message');
      >
      > My problem: secondWindow and secondWindowDoc ument seem to need
      > to be passed as references to this OpenSecondWindo w
      > 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
      >[/color]

      and my reply is:
      Prior to validation create a variable
      var errorMessage = "The following errors were detected in your form:"
      At each error add a line to the errorMessage
      errorMessage += "\nError xxxxx"
      At the end
      alert(errorMess age)

      --
      Dennis M. Marks

      Replace domain.invalid with dcsi.net


      -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
      http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
      -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

      Comment

      Working...