Close Window Function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • clequieu@nuvell.com

    Close Window Function

    I have created a form. Within the form is a button to close the window
    on click and to validate as well. The close window works when it is a
    stand alone, but it does not work when it is embedded with the other
    code. Here is the code I am currently using:

    <p><font face="Trebuchet MS">
    <input type="submit" value="Send" name="B1"
    onClick="Javasc ript:window.clo se()" "MM_validateFor m('Manager
    Name','','R','M anagers Extension','',' R','Department' ,'','R');return
    document.MM_ret urnValue">
    <input type="reset" value="Clear" name="B2">
    </font></p>

    Any help you can give me will be greatly appreciated.

    Cat

  • kaeli

    #2
    Re: Close Window Function

    In article <1113424385.717 635.72000@f14g2 000cwb.googlegr oups.com>,
    clequieu@nuvell .com enlightened us with...[color=blue]
    > I have created a form. Within the form is a button to close the window
    > on click and to validate as well. The close window works when it is a
    > stand alone, but it does not work when it is embedded with the other
    > code. Here is the code I am currently using:
    >
    > <p><font face="Trebuchet MS">
    > <input type="submit" value="Send" name="B1"
    > onClick="Javasc ript:window.clo se()" "MM_validateFor m('Manager
    > Name','','R','M anagers Extension','',' R','Department' ,'','R');return
    > document.MM_ret urnValue">
    > <input type="reset" value="Clear" name="B2">
    > </font></p>
    >
    > Any help you can give me will be greatly appreciated.[/color]

    How can it validate *after* it closes itself?
    Think about it. ;)

    I think you wanted validation, then closing if successful, yes?
    And ditch the "javascript :" stuff in an event.

    <input type="submit" value="Send" name="B1"
    onClick="if (MM_validateFor m('Manager
    Name','','R','M anagers Extension','',' R','Department' ,'','R')) window.close
    ();>

    That assumes MM_validateForm returns a true/false or equivalent value that
    the "if" can evaluate to t/f.

    --
    --
    ~kaeli~
    You can't have everything. Where would you put it?



    Comment

    • Hywel Jenkins

      #3
      Re: Close Window Function

      In article <1113424385.717 635.72000@f14g2 000cwb.googlegr oups.com>,
      clequieu@nuvell .com says...[color=blue]
      > I have created a form. Within the form is a button to close the window
      > on click and to validate as well. The close window works when it is a
      > stand alone, but it does not work when it is embedded with the other
      > code. Here is the code I am currently using:
      >
      > <p><font face="Trebuchet MS">
      > <input type="submit" value="Send" name="B1"
      > onClick="Javasc ript:window.clo se()" "MM_validateFor m('Manager
      > Name','','R','M anagers Extension','',' R','Department' ,'','R');return
      > document.MM_ret urnValue">
      > <input type="reset" value="Clear" name="B2">
      > </font></p>
      >
      > Any help you can give me will be greatly appreciated.[/color]

      Your code is screwed. javascript: isn't required - by definition
      whatever you put in the onclick even is scripting. You're trying to
      have multiple values for the onclick event - you can't. You need
      something like this:

      onClick="
      window.close();
      MM_validateForm ('Manager Name','','R','M anagers
      Extension','',' R','Department' ,'','R');
      return document.MM_ret urnValue;"

      Of course, your window will close before the validation runs anyway.
      What's the point of running a validation before you close the window -
      what happens with the form data you're trying to validate? If you're
      closing the window without performing some sort of processing on the
      input, why bother with the input at all?

      There should be an apostrophe in "Managers Extension", too, but that
      will no doubt cause you another problem.

      --
      Hywel

      Comment

      • RobG

        #4
        Re: Close Window Function

        Hywel Jenkins wrote:[color=blue]
        > In article <1113424385.717 635.72000@f14g2 000cwb.googlegr oups.com>,
        > clequieu@nuvell .com says...
        >[color=green]
        >>I have created a form. Within the form is a button to close the window
        >>on click and to validate as well. The close window works when it is a
        >>stand alone, but it does not work when it is embedded with the other
        >>code. Here is the code I am currently using:
        >>
        >> <p><font face="Trebuchet MS">
        >> <input type="submit" value="Send" name="B1"
        >>onClick="Java script:window.c lose()" "MM_validateFor m('Manager
        >>Name','','R', 'Managers Extension','',' R','Department' ,'','R');return
        >>document.MM_r eturnValue">
        >> <input type="reset" value="Clear" name="B2">
        >> </font></p>
        >>
        >>Any help you can give me will be greatly appreciated.[/color]
        >[/color]

        [...]
        [color=blue]
        >
        > There should be an apostrophe in "Managers Extension", too, but that
        > will no doubt cause you another problem.
        >[/color]

        Not only but also...

        If "Managers Extension" is intended to be the name of a form element,
        and it seems likely that it is, then neither the space nor the
        suggested grammatically correct but syntactically erroneous
        apostrophe are legal characters.

        The HTML rules for id and name tokens are:

        "# ID and NAME tokens must begin with a letter ([A-Za-z]) and may
        be followed by any number of letters, digits ([0-9]), hyphens
        ("-"), underscores ("_"), colons (":"), and periods (".")."

        <URL:http://www.w3.org/TR/html4/types.html#type-cdata>

        i.e. spaces and quotes are not allowed as part of names or ids.

        --
        Rob

        Comment

        • RobB

          #5
          Re: Close Window Function

          clequieu@nuvell .com wrote:[color=blue]
          > I have created a form. Within the form is a button to close the[/color]
          window[color=blue]
          > on click and to validate as well. The close window works when it is[/color]
          a[color=blue]
          > stand alone, but it does not work when it is embedded with the other
          > code. Here is the code I am currently using:
          >
          > <p><font face="Trebuchet MS">
          > <input type="submit" value="Send" name="B1"
          > onClick="Javasc ript:window.clo se()" "MM_validateFor m('Manager
          > Name','','R','M anagers Extension','',' R','Department' ,'','R');return
          > document.MM_ret urnValue">
          > <input type="reset" value="Clear" name="B2">
          > </font></p>
          >
          > Any help you can give me will be greatly appreciated.
          >
          > Cat[/color]

          <body...onunloa d="self.close() ">
          ...............
          ...............
          <form....onsubm it="MM_validate Form('Manager
          Name','','R','M anagers Extension','',' R','Department' ,'','R');return
          document.MM_ret urnValue">
          ........
          ........
          <input type="submit" value="Send" name="B1">
          <input type="reset" value="Clear" name="B2">

          Comment

          • Richard Cornford

            #6
            Re: Close Window Function

            RobG wrote:[color=blue]
            > Hywel Jenkins wrote:[/color]
            <sbnip>[color=blue][color=green]
            >> There should be an apostrophe in "Managers Extension", too,
            >> but that will no doubt cause you another problem.
            >>[/color]
            >
            > Not only but also...
            >
            > If "Managers Extension" is intended to be the name of a form
            > element, and it seems likely that it is, then neither the space nor
            > the suggested grammatically correct but syntactically erroneous
            > apostrophe are legal characters.[/color]

            The name attributes of A, MAP, IMG, OBJECT, PARAM, APPLET, FORM, INPUT,
            SELECT, TEXTAREA, BUTTON, FRAME and IFRAME elements (where present in
            the pertinent DTDs) are specified as CDATA, and may contain any
            characters "from the document character set" (some with some additional
            restrictions).

            The ID and NAME _tokens_ apply to ID attributes, the NAME attributes of
            META elements and a number of other attributes (but not other NAME
            attributes).
            [color=blue]
            > The HTML rules for id and name tokens are:[/color]
            ^^^^^^[color=blue]
            >
            > "# ID and NAME tokens must begin with a letter ([A-Za-z]) and may
            > be followed by any number of letters, digits ([0-9]), hyphens
            > ("-"), underscores ("_"), colons (":"), and periods (".")."
            >
            > <URL:http://www.w3.org/TR/html4/types.html#type-cdata>
            >
            > i.e. spaces and quotes are not allowed as part of names or ids.[/color]

            They are allowed as parts of the names in a form control element's NAME
            attribute. But as they are illegal in javascript Identifiers controls
            using those characters cannot be referenced with dot notation property
            accessors, and bracket notation accessors would have to be used instead.

            Richard.


            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: Close Window Function

              Hywel Jenkins wrote:
              [color=blue]
              > [...]
              > You're trying to have multiple values for the onclick event - you can't.
              > You need something like this:
              >
              > onClick="
              > window.close();
              > MM_validateForm ('Manager Name','','R','M anagers[/color]
              ^^^^^^^^^^^^^^^[1] ^^^^^^^^^[2][color=blue]
              > Extension','',' R','Department' ,'','R');
              > return document.MM_ret urnValue;"[/color]

              [1] I recommend against using Macromedia's scripts. They are known
              to be ill-designed and therefore error-prone (later reference
              to `document.MM_re turnValue' again suggests so).

              [2] I don't think this is going to work since the string is unterminated
              (unintentionall y?). Try this instead:

              onclick="window .close();
              MM_validateForm ('Manager Name', '', 'R', 'Manager\'s Extension',
              '', 'R', 'Department', '', 'R');
              return document.MM_ret urnValue;"

              But due to the nonsense of preceding window.close(), I think the OP rather
              wants something like this:

              in sender.html:

              function validateForm(fo rmReference)
              {
              if (validationWasU nsuccessful)
              {
              return false;
              }

              return true;
              }

              <form action="receive r" ... onsubmit="retur n validateForm(th is);" ...>
              ...
              <input type="submit" value="...">
              </form>

              in receiver:

              <body ... onload="window. close();" ...>
              ...
              </body>
              [color=blue]
              > [...]
              > There should be an apostrophe in "Managers Extension", too, but that
              > will no doubt cause you another problem.[/color]

              I don't think so , see above :)


              PointedEars

              Comment

              Working...