Bonjour jai un formulaire qui apparais dans un popup qui ce nome « popup » voici le script de mon formulaire.
Ce que je narrive pas a faire c fermer les 2 popup après validation du form ( le popup de validation ce ferme bien,, mais pas le popup ce lui du formulaire.
Popup.php
<html>
<head>
<script language="javascript" type="text/javascript">
function verif()
{
var nom = document.formulaire.nom.value;
if (document.formulaire.nom.value == "")
{
alert ('Veuillez entrer votre nom');
document.formulaire.nom.focus();
return false;
}
if(document.formulaire.prenom.value == "")
{
alert ('Veuillez entrer votre prénom');
document.formulaire.prenom.focus();
return false;
}
if(document.formulaire.matricule.value == "")
{
alert ('Veuillez entrer votre matricule');
document.formulaire.matricule.focus();
return false;
}
if(document.formulaire.matricule.value.length != 4)
{
alert ('Le matricule doit comporter 4 chiffres');
document.formulaire.matricule.focus();
return false;
}
if(document.formulaire.telephone.value == "")
{
alert ('Veuillez entrer un n° de téléphone');
document.formulaire.telephone.focus();
return false;
}
if(document.formulaire.telephone.value.length != 6)
{
alert ('Le n° de téléphone doit comporter 6 chiffres');
document.formulaire.telephone.focus();
return false;
}
else
{
if(window.document.all('flag').innerHTML="false"){
resum();
return false;
}else{
return true;
}
}
}
function resum(){
html= "";
html += " <head>";
html += " <style>";
html += " body, table, tr,td{";
html += " background-color: #FFFFCC;";
html += " color: #009900;";
html += " font-family: Verdana, Arial, Courrier;";
html += " font-size: 10px;";
html += " }";
html += " </style>";
html += " </head>";
html += " <body>";
html += "<i>Merci de prendre le temps de vérifier ce que vous venez de saisir:<br> ( coordonnées, téléphone ou e-mail et la date).</i>";
html += "<p/><strong> Merci !</strong><p/>";
html += " <table>";
html += " <tr>";
html += " <td><b>Nom</b></td>";
html += " <td>: ";
html += document.formulaire.nom.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td><b>Prénom</b></td>";
html += " <td>: ";
html += document.formulaire.prenom.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td><b<Matricule</b></td>";
html += " <td>: ";
html += document.formulaire.matricule.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td><b>Téléphone</td>";
html += " <td>: ";
html += document.formulaire.telephone.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td><b>E-mail</b></td>";
html += " <td>: ";
html += document.formulaire.courriel.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td><b>Date choisie</b></td>";
html += " <td>: ";
html += document.formulaire.select.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td><b>Commentaire éventuel</b></td>";
html += " <td>: ";
html += document.formulaire.textarea.value;
html += " </td>";
html += " </tr>";
html += " <tr>";
html += " <td colspan='2'>";
html += " <button onclick='window.opener.document.all(\"flag\").innerHTML=\"true\";window.opener.document.formulaire.submit();self.close();'>Je confirme</button>";
html += " <button onclick='self.close();'>Je veux modifier</button>";
html += " </td>";
html += " </tr>";
html += " <table>";
html += " </body>";
Fenetreresum = window.open('','Vérification','scrollbars=no,resizable=no,toolbar=no,status=no,top=220,left=250,width=420,height=300')
Fenetreresum.document.write(html);
}
</script>
</head>
<body>
<form name="formulaire" method="post" action="index2.php">
<table>
<tr>
<td>Nom:</td>
<td><input type="" name="nom" value="nom" /></td>
</tr>
<tr>
<td>Prénom:</td>
<td><input type="" name="prenom" value="fred" /></td>
</tr>
<tr>
<td>Matricule:</td>
<td><input type="" name="matricule" value="1234" /></td>
</tr>
<tr>
<td>Téléphone:</td>
<td><input type="" name="telephone" value="123456" /></td>
</tr>
<tr>
<td>Courriel:</td>
<td><input type="" name="courriel" value="Mon_mail@fai.fr" /></td>
</tr>
<tr>
<td>Date:</td>
<td>
<select name="select">
<option value="01/04/2006">01/04/2006</option>
<option value="01/10/2006">01/10/2006</option>
</select>
</tr>
<tr>
<td>Commentaire:</td>
<td><textarea cols="40" rows="5" name="textarea" value="">Juste pour tester.</textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" onclick="javascript: return verif();"/> <input type="reset"/>
<td colspan='2'>";
</td>
</tr>
</table>
</form>
<div id="flag" name="flag" style="display: none;">false</div>
</body>
</html>
Et voici juste le script javascript douverture de la popup de ma page index2.html
</script>
<script language="javascript">
function popupcentree(page,largeur,hauteur,options)
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
window.open(page,"popup","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
</script>
Merci de votre aide !!