Close Window Function

C

clequieu

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
 
K

kaeli

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.

<input type="submit" value="Send" name="B1"
onClick="if (MM_validateForm('Manager
Name','','R','Managers 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.

--
 
H

Hywel Jenkins

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:

onClick="
window.close();
MM_validateForm('Manager Name','','R','Managers
Extension','','R','Department','','R');
return document.MM_returnValue;"

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.
 
R

RobG

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

<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.
 
R

RobB

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

<body...onunload="self.close()">
...............
...............
<form....onsubmit="MM_validateForm('Manager
Name','','R','Managers Extension','','R','Department','','R');return
document.MM_returnValue">
........
........
<input type="submit" value="Send" name="B1">
<input type="reset" value="Clear" name="B2">
 
R

Richard Cornford

RobG said:
Hywel Jenkins wrote:

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.

Richard.
 
T

Thomas 'PointedEars' Lahn

Hywel said:
[...]
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','Managers
^^^^^^^^^^^^^^^[1] ^^^^^^^^^[2]
Extension','','R','Department','','R');
return document.MM_returnValue;"

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

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

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

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

in sender.html:

function validateForm(formReference)
{
if (validationWasUnsuccessful)
{
return false;
}

return true;
}

<form action="receiver" ... onsubmit="return validateForm(this);" ...>
...
<input type="submit" value="...">
</form>

in receiver:

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

I don't think so , see above :)


PointedEars
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top