PDA

View Full Version : close window


Detlef
04-01-2001, 06:51 PM
Hi,
I´ve got a form, which opens via a script in a
popup-window.
Now what I´d like to have is that this popup-
window closes automatically as soon as the
visitor hits the submit-button.
I couldn´t manage that.
Anybody else can?

Ian
04-01-2001, 07:05 PM
Hi, please post your form script.

Thanks

Detlef
04-01-2001, 07:51 PM
Here it is:

<HTML>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function feldleer_kontrolle(wert)
{
/* Diese Funktion überprüft, ob der übergebene Wert leer ist */
if (wert=="")
{
return false;
}
else
{
return true;
}
}


function globale_kontrolle()
{

var fehlerzahl = 0; // Anzahl der nicht gefüllten Felder
var fehlermeldung = "Ihr Formular ist nicht vollständig ausgefüllt!\nFolgende Angaben sind noch notwendig:\n";
if (!feldleer_kontrolle(document.Formular1.Nachname.value))
{
fehlerzahl = fehlerzahl + 1;
fehlermeldung = fehlermeldung + fehlerzahl + ". Bitte Geben Sie Ihren Nachnamen an\n";
}
if (!feldleer_kontrolle(document.Formular1.Vorname.value))
{
fehlerzahl = fehlerzahl + 1;
fehlermeldung = fehlermeldung + fehlerzahl + ". Bitte Geben Sie Ihren Vornamen an\n";
}
if (!feldleer_kontrolle(document.Formular1.Strasse.value))
{
fehlerzahl = fehlerzahl + 1;
fehlermeldung = fehlermeldung + fehlerzahl + ". Bitte Geben Sie Ihre Straße und Hausnummer an\n";
}
if (!feldleer_kontrolle(document.Formular1.PLZ.value))
{
fehlerzahl = fehlerzahl + 1;
fehlermeldung = fehlermeldung + fehlerzahl + ". Bitte Geben Sie Ihre Postleitzahl an\n";
}
if (!feldleer_kontrolle(document.Formular1.Ort.value))
{
fehlerzahl = fehlerzahl + 1;
fehlermeldung = fehlermeldung + fehlerzahl + ". Bitte Geben Sie Ihr Ort an\n";
}
/* Die Rückgabe, ob das Formular noch fehlerhaft ist oder nicht */
if (fehlerzahl == 0)
{
// Keine Fehler gefunden
return true;
}
else
{
// Fehler vorhanden
fehlermeldung = fehlermeldung + "Das Formular kann erst abgeschickt werden,\nwenn die entsprechenden Felder ausgefüllt sind!!";
alert(fehlermeldung);
return false;
}
}
-->
</SCRIPT>
</head>
<BODY bgcolor="#CCCCFF">
<h1 align=center>Diese Formular wird nur überprüft abgeschickt</h1>
Geben Sie bitte Ihre persönlichen Daten ein (verpflichtende Angaben):
<p>
<FORM ACTION="mailto:info@schluesseldienst-dethlefs.de" method=POST ENCTYPE="text/plain" name="Formular1" onSubmit="return globale_kontrolle();Close.Window">

<fieldset style="BORDER-BOTTOM-COLOR: #6385ED; BORDER-LEFT-COLOR: #6385ED; BORDER-RIGHT-COLOR: #6385ED; BORDER-TOP-COLOR: #6385ED; PADDING-BOTTOM: 20px; PADDING-LEFT: 20px; PADDING-RIGHT: 20px; PADDING-TOP: 20px; WIDTH: 600px;HEIGHT: 300px">
<legend align=left style="COLOR: #000080"><b>Anfrage-Formular</b></legend>


<DIV align=right>
<INPUT TYPE=submit style="BACKGROUND-COLOR: #66FFFF ;border-bottom-color: #6699FF;
border-top-color: #3300FF"
VALUE="Formular abschicken">
</DIV>


<div style="position:absolute; top:240px; left:130px; z-index:1;"><INPUT NAME="Nachname" SIZE=20 MAXLENGTH=30 onFocus="window.status='Geben Sie hier Ihren Nachnamen ein'">
</a></div>
<div style="position:absolute; top:243px; left:20px; z-index:1; font-size:12pt;">Nachname:
</a></div>
<div style="position:absolute; top:270px; left:130px; z-index:1;"><INPUT NAME="Vorname" SIZE=20 MAXLENGTH=30 onFocus="window.status='Geben Sie hier Ihren Vornamen ein'">
</a></div>
<div style="position:absolute; top:273px; left:20px; z-index:1; font-size:12pt;">Vorname:
</a></div>
<div style="position:absolute; top:300px; left:130px; z-index:1;"><INPUT NAME="Strasse" SIZE=20 MAXLENGTH=30 onFocus="window.status='Geben Sie hier Straße und Hausnummer ein'">
</a></div>
<div style="position:absolute; top:303px; left:20px; z-index:1; font-size:12pt;">Straße/ Hausnr.:
</a></div>
<div style="position:absolute; top:330px; left:130px; z-index:1;"><INPUT NAME="PLZ" SIZE=20 MAXLENGTH=30 onFocus="window.status='Geben Sie hier die Postleitzahl ein'">
</a></div>
<div style="position:absolute; top:333px; left:20px; z-index:1; font-size:12pt;">PLZ:
</a></div>
<div style="position:absolute; top:360px; left:130px; z-index:1;"><INPUT NAME="Ort" SIZE=20 MAXLENGTH=30 onFocus="window.status='Geben Sie hier den Ort ein'">
</a></div>
<div style="position:absolute; top:363px; left:20px; z-index:1; font-size:12pt;">Ort:
</a></div>
</FORM>
</BODY>
</HTML>

You can ignore the first function; it´s only
ther to check if the visitor has filled out
all the fields.
The "onSubmit"-tag is the one. I simply added
"close.window", but it doesn´t work.

Hope you can help!

Ian
04-01-2001, 08:03 PM
you were pretty close :)
try:

onSubmit="return globale_kontrolle();window.close()"

I hope that works.

Detlef
04-02-2001, 11:23 AM
Hi,
lamentably this doesn´t work, either.
Any other idea?

Ian
04-02-2001, 12:22 PM
I wondered if it would or not, sometimes javascript only executes the first function of a submit form. try adding it direct to your submit button.

<INPUT TYPE=submit style="BACKGROUND-COLOR: #66FFFF ;border-bottom-color: #6699FF;
border-top-color: #3300FF"
VALUE="Formular abschicken" onClick="window.close()">

not sure if that will work either, but only one way to find out :)