Close Window Function

Discussion in 'Javascript' started by clequieu@nuvell.com, Apr 13, 2005.

Guest

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:

Advertisements

In article <>, enlightened us with...
> 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="Javascript:window.close()" "MM_validateForm('Manager
> Name','','R','Managers Extension','','R','Department','','R');return
> document.MM_returnValue">
> <input type="reset" value="Clear" name="B2">
> </font></p>
>
> Any help you can give me will be greatly appreciated.

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.

Advertisements

In article <>, says...
> 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="Javascript:window.close()" "MM_validateForm('Manager
> Name','','R','Managers Extension','','R','Department','','R');return
> document.MM_returnValue">
> <input type="reset" value="Clear" name="B2">
> </font></p>
>
> Any help you can give me will be greatly appreciated.

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:

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 Jenkins wrote:
> In article <>,
> says...
>
>>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="Javascript:window.close()" "MM_validateForm('Manager
>>Name','','R','Managers Extension','','R','Department','','R');return
>>document.MM_returnValue">
>> <input type="reset" value="Clear" name="B2">
>> </font></p>
>>
>>Any help you can give me will be greatly appreciated.
>

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

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 (".")."

wrote:
> 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="Javascript:window.close()" "MM_validateForm('Manager
> Name','','R','Managers Extension','','R','Department','','R');return
> document.MM_returnValue">
> <input type="reset" value="Clear" name="B2">
> </font></p>
>
> Any help you can give me will be greatly appreciated.
>
> Cat

RobG wrote:
> Hywel Jenkins wrote:
<sbnip>
>> There should be an apostrophe in "Managers Extension", too,
>> but that will no doubt cause you another problem.
>>
>
> 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 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).
> 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.

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.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!