IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

debuggage de Fonctions javascript


Sujet :

JavaScript

  1. #1
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut debuggage de Fonctions javascript
    Bonjour à tous

    les fonctions de javascript de mon formulaire ne marche plus

    alors quand j'execute le formulaire appare mes fonctions marchent bien

    avec ce code mes fonctions tournent bien

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
     
    <head>
    <script type="text/javascript">
    function changeBackgroundColor(elemnt)
    {
     
             if (elemnt) {   
              elemnt.style.backgroundColor = "yellow";
       }
              return;
    }
     
    function verify()
    	{
    		tt = document.getElementsByTagName("form");
    		if (tt[0].Code.value=="")
    		{
    			alert("Saisir Votre Code SVP!");
    			tt[0].Code.focus();
                            changeBackgroundColor(document.clientform.Code);
    			return false;
    		}
    		else
    		{
    			document.clientform.action="Enseignant.php?mode=control";
    			document.clientform.submit();
    			return true;
    		}
    	}
     
     
    function ajout()
    	{
    		chp = document.getElementsByTagName("form");
    		if (chp[0].CodE.value=="" || chp[0].NomE.value=="" || chp[0].PrenE.value=="" || chp[0].AdrE.value=="" || chp[0].ViE.value=="" || chp[0].TelE.value==""  || chp[0].emailE.value=="")
    		{
    			alert("Remplir tous les champs SVP!");
    			chp[0].CodE.focus();
                            changeBackgroundColor(document.clientform2.CodE);
    			return false;
    		}
    		else
    		{
    			if (isNaN(chp[0].TelE.value))
    			{
    				alert("Numero Invalide!");
    				chp[0].TelE.focus();
                                    changeBackgroundColor(document.clientform2.TelE);
    				return false;
                          }
     
    			else
    			{
    				document.clientform2.action="Enseignant.php?mode=add";
    				document.clientform2.submit();
    				return true;
    			}
    		}
    	}
    </script>
    <style type="text/css"><!--
      .bold_right {font-weight: bold; text-align: right;}
      .gray_banner { font-weight: bold; color: white; 
                     background-color: gray; 
                     text-align: center; font-size: 3em;}
      .bold_large {font-size: 1.1em; font-weight: bold;}
    -->
    </style>
    </head>
    <table border="0" cellpadding="5" cellspacing="0">
       <tr><td colspan="3" class="gray_banner">
            Enseignant ou futurs enseignants</td></tr>
       <tr><td width="40%" valign="top" class="bold_large">
             Etes-vous d&eacute;ja membre ?
             <br><br><br><br><br>
           <form name="clientform" method="post" action="index.php?page=best.htm">
             <p><table border="0">
     <tr>
      	<td><font color="#FF3300">Veuillez saisir le code de sécurité:</font></td>
    	<td><input type="text" name="Code"></td>
      </tr>
      <tr>
     
               <td style="text-align: center" colspan="2">
                    <br><input type="button" value="Identifiez-vous" onClick="verify();"></td>
        </tr>
    </table>
     
           </td>
           <td style="width: 1; background-color: gray"></td>
           <td style="width: 70%"><p>
             <span class="bold_large"></p>
       <!-- formulaire à renseigner par les nouveaux membres -->
     
           <form name="clientform2" method="post" action="index.php?page=best.htm"> 
             <table border="0" width="100%">
     
    <tr><td class="bold_right">Code Enseignant</td>
                   <td><input type="text" name="CodE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Nom</td>
                   <td><input type="text" name="NomE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Prenom</td>
                   <td><input type="text" name="PrenE" 
                          size="20" maxlength="20"></td></tr>
     
    <tr><td class="bold_right">Adresse</td>
                   <td><input type="text" name="AdrE" 
                          size="20" maxlength="20"></td></tr>
     
     
    <tr><td class="bold_right">Ville</td>
                   <td><input type="text" name="ViE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Telephone</td>
                   <td><input type="text" name="TelE" 
                          size="15" maxlength="20"></td></tr>
     
                <tr><td class="bold_right">Adresse Email</td>
                   <td><input type="text" name="emailE" 
                          size="55" maxlength="67"></td></tr>
     
    <tr>
              <td style="text-align: center" colspan="2">
     
                     <input type="button" value="Enregistrez-vous" onClick="ajout();" >   
     
    		 <input type="reset" style="text-align: center" value ="R&eacute;tablir" ></td>
     
    </tr>
     
             </table>
            </form>
           </td>
       </tr>
       <tr><td colspan="3" 
               style="background-color: gray">&nbsp;</td></tr>
    </table>
    <div style="text-align: center; font-size: .8em">
    Nous appr&eacute;cierions vos commentaires et suggestions. Vous pouvez
    les adresser a <a href="mailto:@gmail.com">
        X@gmail.com</a></div>

    mais quand j'execute ce formulaire dans cette page rien ne marche


    Merci de votre Aide

  2. #2
    Rédacteur
    Avatar de jsd03
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Août 2008
    Messages
    1 221
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information

    Informations forums :
    Inscription : Août 2008
    Messages : 1 221
    Points : 6 506
    Points
    6 506
    Par défaut
    Tu as regardé la console d'erreur javascript ? (je parle pour Firefox)

    Parce que à parament il y a plein de chose qui ne vont pas quand on soumet ton formulaire (la première fois sans rien remplir) :

    - Erreur*: Permission refusée d'appeler la méthode Location.toString
    - Erreur*: optimost is not defined
    Fichier Source*: http://www.answerbag.com/q_view/19865
    Ligne*: 795
    - Erreur*: a is null
    Fichier Source*: http://conexance.cxp.02:8088/org.tal...938.cache.html
    Ligne*: 53
    - Erreur*: K is undefined
    Fichier Source*: http://conexance.cxp.02:8088/org.tal...ext/ext-all.js
    Ligne*: 141
    ...

    Pense à utiliser un debugger à l'avenir. Comme le module Web developper toolbar ou/ Firebug de Firefox.
    Google est ton ami mais ton voisin aussi

    Modérateur BI - Responsable Talend
    Mes tutoriels - FAQ Talend - FAQ SQL*Plus

    Avant toute chose : lire le mode d'emploi du forum et ses règles.
    Suivez @Developpez sur twitter !

  3. #3
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut
    Merci jsd03 pour la rapidite de reponse

    Citation
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Tu as regardé la console d'erreur javascript ? (je parle pour Firefox)
    je viens de regarder le console et j'ai trouvee ses erreurs

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Erreur*: tt[0].Code is undefined
    Fichier Source*: http://127.0.0.1/dossier/index.php?page=best.htm
    Ligne*: 101
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Erreur*: chp[0].CodE is undefined
    Fichier Source*: http://127.0.0.1/dossier/index.php?page=best.htm
    Ligne*: 120
    Citation
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    Parce que à parament il y a plein de chose qui ne vont pas quand on soumet ton formulaire (la première fois sans rien remplir) : 
     
    - Erreur*: Permission refusée d'appeler la méthode Location.toString
    - Erreur*: optimost is not defined
    Fichier Source*: http://www.answerbag.com/q_view/19865
    Ligne*: 795
    - Erreur*: a is null
    Fichier Source*: http://conexance.cxp.02:8088/org.tal...938.cache.html
    Ligne*: 53
    - Erreur*: K is undefined
    Fichier Source*: http://conexance.cxp.02:8088/org.tal...ext/ext-all.js
    Ligne*: 141
    ...
    j'ai rien comprise

    je solicite votre aide pas a pas

  4. #4
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    Je pense que tu devrais revoir la structure du code HTML, parce que les imbrications de table multiples et de form, les navigateurs n'aiment pas trop ça...
    Ensuite, commence déjà pour le JavaScript par remplacer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    tt = document.getElementsByTagName("form");
    ...
    chp = document.getElementsByTagName("form");
    par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    tt = document.forms;
    ...
    chp = document.forms;
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  5. #5
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut
    Merci Bovino d'avoir prit le temps pour me repondre

    ben mais j'ai remplacee les lignes au niveau de mon code mais rien ne change

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
     
    <head>
    <script type="text/javascript">
    function changeBackgroundColor(elemnt)
    {
     
             if (elemnt) {   
              elemnt.style.backgroundColor = "yellow";
       }
              return;
    }
     
    function verify()
    	{
    		tt = document.forms;
    		if (tt[0].Code.value=="")
    		{
    			alert("Saisir Votre Code SVP!");
    			tt[0].Code.focus();
                            changeBackgroundColor(document.clientform.Code);
    			return false;
    		}
    		else
    		{
    			document.clientform.action="Enseignant.php?mode=control";
    			document.clientform.submit();
    			return true;
    		}
    	}
     
     
    function ajout()
    	{
    		chp = document.forms;
    		if (chp[0].CodE.value=="" || chp[0].NomE.value=="" || chp[0].PrenE.value=="" || chp[0].AdrE.value=="" || chp[0].ViE.value=="" || chp[0].TelE.value==""  || chp[0].emailE.value=="")
    		{
    			alert("Remplir tous les champs SVP!");
    			chp[0].CodE.focus();
                            changeBackgroundColor(document.clientform2.CodE);
    			return false;
    		}
    		else
    		{
    			if (isNaN(chp[0].TelE.value))
    			{
    				alert("Numero Invalide!");
    				chp[0].TelE.focus();
                                    changeBackgroundColor(document.clientform2.TelE);
    				return false;
                          }
     
    			else
    			{
    				document.clientform2.action="Enseignant.php?mode=add";
    				document.clientform2.submit();
    				return true;
    			}
    		}
    	}
    </script>
    <style type="text/css"><!--
      .bold_right {font-weight: bold; text-align: right;}
      .gray_banner { font-weight: bold; color: white; 
                     background-color: gray; 
                     text-align: center; font-size: 3em;}
      .bold_large {font-size: 1.1em; font-weight: bold;}
    -->
    </style>
    </head>
    <table border="0" cellpadding="5" cellspacing="0">
       <tr><td colspan="3" class="gray_banner">
            Enseignant ou futurs enseignants</td></tr>
       <tr><td width="40%" valign="top" class="bold_large">
             Etes-vous d&eacute;ja membre ?
             <br><br><br><br><br>
           <form name="clientform" method="post" action="index.php?page=best.htm">
             <p><table border="0">
     <tr>
      	<td><font color="#FF3300">Veuillez saisir le code de sécurité:</font></td>
    	<td><input type="text" name="Code"></td>
      </tr>
      <tr>
     
               <td style="text-align: center" colspan="2">
                    <br><input type="button" value="Identifiez-vous" onClick="verify();"></td>
        </tr>
    </table>
     
           </td>
           <td style="width: 1; background-color: gray"></td>
           <td style="width: 70%"><p>
             <span class="bold_large"></p>
       <!-- formulaire à renseigner par les nouveaux membres -->
           <form name="clientform2" method="post" action="index.php?page=best.htm"> 
             <table border="0" width="100%">
     
    <tr><td class="bold_right">Code Enseignant</td>
                   <td><input type="text" name="CodE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Nom</td>
                   <td><input type="text" name="NomE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Prenom</td>
                   <td><input type="text" name="PrenE" 
                          size="20" maxlength="20"></td></tr>
     
    <tr><td class="bold_right">Adresse</td>
                   <td><input type="text" name="AdrE" 
                          size="20" maxlength="20"></td></tr>
     
     
    <tr><td class="bold_right">Ville</td>
                   <td><input type="text" name="ViE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Telephone</td>
                   <td><input type="text" name="TelE" 
                          size="15" maxlength="20"></td></tr>
     
                <tr><td class="bold_right">Adresse Email</td>
                   <td><input type="text" name="emailE" 
                          size="55" maxlength="67"></td></tr>
     
    <tr>
              <td style="text-align: center" colspan="2">
     
                     <input type="button" value="Enregistrez-vous" onClick="ajout();" >   
     
    		 <input type="reset" style="text-align: center" value ="R&eacute;tablir" ></td>
     
    </tr>
     
             </table>
            </form>
           </td>
       </tr>
       <tr><td colspan="3" 
               style="background-color: gray">&nbsp;</td></tr>
    </table>
    <div style="text-align: center; font-size: .8em">
    Nous appr&eacute;cierions vos commentaires et suggestions. Vous pouvez
    les adresser a <a href="mailto:@gmail.com">
        X@gmail.com</a></div>
    Remarque:je fais appel la page best.htm depuis la page index.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
     
    <?php
    $pages_possibles = array("home.htm", "best.htm", "contact.php", "autre_page.htm");
    if (in_array(@$_GET['page'],$pages_possibles)) { $page = $_GET['page']; }
    else { $page = "home.htm"; }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    <head>
    <title>Corrosion</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <link href="style.css" type="text/css" rel="stylesheet" media="screen"/>
     
    </head>
    <body>
    <div id="global">
    <div id="entete">
    <?php include("entete.htm"); ?>
    </div>
    <div id="menu">
    <?php include('espacepro.htm'); ?>
    <?php include("menu.htm"); ?>
    </div>
    <div id="contenu">
    <?php include($page); ?>
    </div>
    <div id="footer">
    <?php include("footer.htm"); ?></div>
    </div>
    </div>
    </body>
    </html>
    <erci de votre aide

  6. #6
    Invité
    Invité(e)
    Par défaut
    A l'attention de jsd03 et Bovino :
    j'ai envoyé lilia dream sur le forum javascript, car je suis nul en javascript !

    Sa page Best.htm est incluse dans index.php, qui contient deja 1 autre formulaires "espacepro".
    - Si on ouvre la page Best.htm seule, les fonctions javascript fonctionnent.
    - Mais quand on passe par index.php (avec Best.htm incluse), ca ne fonctionne plus.

    espacepro.htm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <!-- #div d identification -->
    <div class="idDiv">
    <form name="espaceproform" method="post" action="index.php?page=identification.php">
    	<b>ESPACE PRO :</b> <a href="#">Code oublié | Aide</a><br />
    	<input type="text" name="id_box" size="20" value="Tapez votre code" onfocus="if (this.value == 'Tapez votre code') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'Tapez votre code'; }" style="text-align:center" id="idBox" />
    	<input type="submit" name="id_value" value="&nbsp;ok&nbsp;" style="margin-top:5px" id="idButton" />
    </form>
    </div>
    Je pense qu'il y a un conflit avec cet autre formulaire, mais perso, je ne sais pas quoi.
    A vous de jouer !

  7. #7
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut
    Merci jreaux62

    j'ai enelevee le head mais toujours ne fonctionne pas

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
     
    <script type="text/javascript">
    function changeBackgroundColor(elemnt)
    {
     
             if (elemnt) {   
              elemnt.style.backgroundColor = "yellow";
       }
              return;
    }
     
    function verify()
    	{
    		tt = document.forms;
    		if (tt[0].Code.value=="")
    		{
    			alert("Saisir Votre Code SVP!");
    			tt[0].Code.focus();
                            changeBackgroundColor(document.clientform.Code);
    			return false;
    		}
    		else
    		{
    			document.clientform.action="Enseignant.php?mode=control";
    			document.clientform.submit();
    			return true;
    		}
    	}
     
     
    function ajout()
    	{
    		chp = document.forms;
    		if (chp[0].CodE.value=="" || chp[0].NomE.value=="" || chp[0].PrenE.value=="" || chp[0].AdrE.value=="" || chp[0].ViE.value=="" || chp[0].TelE.value==""  || chp[0].emailE.value=="")
    		{
    			alert("Remplir tous les champs SVP!");
    			chp[0].CodE.focus();
                            changeBackgroundColor(document.clientform2.CodE);
    			return false;
    		}
    		else
    		{
    			if (isNaN(chp[0].TelE.value))
    			{
    				alert("Numero Invalide!");
    				chp[0].TelE.focus();
                                    changeBackgroundColor(document.clientform2.TelE);
    				return false;
                          }
     
    			else
    			{
    				document.clientform2.action="Enseignant.php?mode=add";
    				document.clientform2.submit();
    				return true;
    			}
    		}
    	}
    </script>
    <style type="text/css"><!--
      .bold_right {font-weight: bold; text-align: right;}
      .gray_banner { font-weight: bold; color: white; 
                     background-color: gray; 
                     text-align: center; font-size: 3em;}
      .bold_large {font-size: 1.1em; font-weight: bold;}
    -->
    </style>
    <table border="0" cellpadding="5" cellspacing="0">
       <tr><td colspan="3" class="gray_banner">
            Enseignant ou futurs enseignants</td></tr>
       <tr><td width="40%" valign="top" class="bold_large">
             Etes-vous d&eacute;ja membre ?
             <br><br><br><br><br>
           <form name="clientform" method="post" action="index.php?page=best.htm">
             <p><table border="0">
     <tr>
      	<td><font color="#FF3300">Veuillez saisir le code de sécurité:</font></td>
    	<td><input type="text" name="Code"></td>
      </tr>
      <tr>
     
               <td style="text-align: center" colspan="2">
                    <br><input type="button" value="Identifiez-vous" onClick="verify();"></td>
        </tr>
    </table>
     
           </td>
           <td style="width: 1; background-color: gray"></td>
           <td style="width: 70%"><p>
             <span class="bold_large"></p>
       <!-- formulaire à renseigner par les nouveaux membres -->
           <form name="clientform2" method="post" action="index.php?page=best.htm"> 
             <table border="0" width="100%">
     
    <tr><td class="bold_right">Code Enseignant</td>
                   <td><input type="text" name="CodE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Nom</td>
                   <td><input type="text" name="NomE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Prenom</td>
                   <td><input type="text" name="PrenE" 
                          size="20" maxlength="20"></td></tr>
     
    <tr><td class="bold_right">Adresse</td>
                   <td><input type="text" name="AdrE" 
                          size="20" maxlength="20"></td></tr>
     
     
    <tr><td class="bold_right">Ville</td>
                   <td><input type="text" name="ViE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Telephone</td>
                   <td><input type="text" name="TelE" 
                          size="15" maxlength="20"></td></tr>
     
                <tr><td class="bold_right">Adresse Email</td>
                   <td><input type="text" name="emailE" 
                          size="55" maxlength="67"></td></tr>
     
    <tr>
              <td style="text-align: center" colspan="2">
     
                     <input type="button" value="Enregistrez-vous" onClick="ajout();" >   
     
    		 <input type="reset" style="text-align: center" value ="R&eacute;tablir" ></td>
     
    </tr>
     
             </table>
            </form>
           </td>
       </tr>
       <tr><td colspan="3" 
               style="background-color: gray">&nbsp;</td></tr>
    </table>
    <div style="text-align: center; font-size: .8em">
    Nous appr&eacute;cierions vos commentaires et suggestions. Vous pouvez
    les adresser a <a href="mailto:@gmail.com">
        X@gmail.com</a></div>
    Merci de votre aide

  8. #8
    Membre émérite
    Inscrit en
    Septembre 2002
    Messages
    2 307
    Détails du profil
    Informations forums :
    Inscription : Septembre 2002
    Messages : 2 307
    Points : 2 814
    Points
    2 814
    Par défaut
    tag form non fermant!

  9. #9
    Rédacteur
    Avatar de jsd03
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Août 2008
    Messages
    1 221
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information

    Informations forums :
    Inscription : Août 2008
    Messages : 1 221
    Points : 6 506
    Points
    6 506
    Par défaut
    Alors première chose rajoute ce-ci en début de code :

    puis rajoute ferme la balise <head> après ta balise </style>

    Ensuite il faut que tu fermes ton premier formulaire pour pouvoir accéder au deuxième, donc rajoute la balise </form> après la première balise </table>.

    Dans ton javascript, change la ligne :

    par

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    tt = document.forms['clientform'];
    et

    par

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    chp = document.forms['clientform2'];
    Ensuite il ne te reste plus qu'à remplacer les "tt[0]" par des "tt" et les "chp[0]" par des chp.

    En gros ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    <html><head>
     
    <script type="text/javascript">
    function changeBackgroundColor(elemnt)
    {
     
             if (elemnt) {   
              elemnt.style.backgroundColor = "yellow";
       }
              return;
    }
     
    function verify()
    	{
    		tt = document.forms['clientform'];
    		if (tt.Code.value=="")
    		{
    			alert("Saisir Votre Code SVP!");
    			tt.Code.focus();
                            changeBackgroundColor(document.clientform.Code);
    			return false;
    		}
    		else
    		{
    			document.clientform.action="Enseignant.php?mode=control";
    			document.clientform.submit();
    			return true;
    		}
    	}
     
     
    function ajout()
    	{
    		chp = document.forms['clientform2'];
    		if (chp.CodE.value=="" || chp.NomE.value=="" || chp.PrenE.value=="" || chp.AdrE.value=="" || chp.ViE.value=="" || chp.TelE.value==""  || chp.emailE.value=="")
    		{
    			alert("Remplir tous les champs SVP!");
    			chp.CodE.focus();
                            changeBackgroundColor(document.clientform2.CodE);
    			return false;
    		}
    		else
    		{
    			if (isNaN(chp.TelE.value))
    			{
    				alert("Numero Invalide!");
    				chp.TelE.focus();
                                    changeBackgroundColor(document.clientform2.TelE);
    				return false;
                          }
     
    			else
    			{
    				document.clientform2.action="Enseignant.php?mode=add";
    				document.clientform2.submit();
    				return true;
    			}
    		}
    	}
    </script>
    <style type="text/css"><!--
      .bold_right {font-weight: bold; text-align: right;}
      .gray_banner { font-weight: bold; color: white; 
                     background-color: gray; 
                     text-align: center; font-size: 3em;}
      .bold_large {font-size: 1.1em; font-weight: bold;}
    -->
    </style>
    </head>
    <table border="0" cellpadding="5" cellspacing="0">
       <tr><td colspan="3" class="gray_banner">
            Enseignant ou futurs enseignants</td></tr>
       <tr><td width="40%" valign="top" class="bold_large">
             Etes-vous d&eacute;ja membre ?
             <br><br><br><br><br>
           <form name="clientform" method="post" action="index.php?page=best.htm">
             <p><table border="0">
     <tr>
      	<td><font color="#FF3300">Veuillez saisir le code de sécurité:</font></td>
    	<td><input type="text" name="Code"></td>
      </tr>
      <tr>
     
               <td style="text-align: center" colspan="2">
                    <br><input type="button" value="Identifiez-vous" onClick="verify();"></td>
        </tr>
    </table>
     
     
     
     
     
    </form>
     
     
     
     
     
           </td>
           <td style="width: 1; background-color: gray"></td>
           <td style="width: 70%"><p>
             <span class="bold_large"></p>
       <!-- formulaire à renseigner par les nouveaux membres -->
           <form name="clientform2" method="post" action="index.php?page=best.htm"> 
             <table border="0" width="100%">
     
    <tr><td class="bold_right">Code Enseignant</td>
                   <td><input type="text" name="CodE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Nom</td>
                   <td><input type="text" name="NomE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Prenom</td>
                   <td><input type="text" name="PrenE" 
                          size="20" maxlength="20"></td></tr>
     
    <tr><td class="bold_right">Adresse</td>
                   <td><input type="text" name="AdrE" 
                          size="20" maxlength="20"></td></tr>
     
     
    <tr><td class="bold_right">Ville</td>
                   <td><input type="text" name="ViE" 
                          size="20" maxlength="20"></td></tr>
     
     <tr><td class="bold_right">Telephone</td>
                   <td><input type="text" name="TelE" 
                          size="15" maxlength="20"></td></tr>
     
                <tr><td class="bold_right">Adresse Email</td>
                   <td><input type="text" name="emailE" 
                          size="55" maxlength="67"></td></tr>
     
    <tr>
              <td style="text-align: center" colspan="2">
     
                     <input type="button" value="Enregistrez-vous" onClick="ajout();" >   
     
    		 <input type="reset" style="text-align: center" value ="R&eacute;tablir" ></td>
     
    </tr>
     
             </table>
            </form>
           </td>
       </tr>
       <tr><td colspan="3" 
               style="background-color: gray">&nbsp;</td></tr>
    </table>
    <div style="text-align: center; font-size: .8em">
    Nous appr&eacute;cierions vos commentaires et suggestions. Vous pouvez
    les adresser a <a href="mailto:@gmail.com">
        X@gmail.com</a></div>
     
     
     
    </body>
    </html>
    Par contre tu verras que les conditions de vérifications des champs sont pas tip top mais déjà tu n'as plus d'erreur javascript. C'est juste de l'algo maintenant.
    Google est ton ami mais ton voisin aussi

    Modérateur BI - Responsable Talend
    Mes tutoriels - FAQ Talend - FAQ SQL*Plus

    Avant toute chose : lire le mode d'emploi du forum et ses règles.
    Suivez @Developpez sur twitter !

  10. #10
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut

    Merci infiniment d'avoir répondu.

    Merci jreaux62
    Merci Matthieu2000 ,Bovino,
    Merci encore jsd03 pour les explications que tu m'as apportés, ils m'étaient très utiles afin que je puisse avoir une meilleure vue pour mon Fomulaire.
    .
    j'ai une question simple je voudrais colorer toutes les champs de mon formulaire comme montrer dans l'image en-dessous

    comment dois-je faire ca?

    Merci encore une fois

  11. #11
    Invité
    Invité(e)
    Par défaut
    Lilia, voici ton code PROPRE !

    Best.htm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    <style type="text/css"><!--
      .bold_right {font-weight: bold; text-align: right;}
      .gray_banner { font-weight: bold; color: white; 
                     background-color: gray; 
                     text-align: center; font-size: 3em;}
      .bold_large {font-size: 1.1em; font-weight: bold;}
    -->
    </style>
    <script type="text/javascript">
     
    function changeBackgroundColor(elemnt)
    {
       if (elemnt) { elemnt.style.backgroundColor = "yellow"; }
       return;
    }
     
    function verify()
    {
       tt = document.forms['clientform'];
       if (tt.Code.value=="")
       {
          alert("Saisir Votre Code SVP!");
          tt.Code.focus();
          changeBackgroundColor(document.clientform.Code);
          return false;
       } else {
          document.clientform.action="Enseignant.php?mode=control";
          document.clientform.submit();
          return true;
       }
    }
     
    function ajout()
    {
       chp = document.forms['clientform2'];
       if (chp.CodE.value=="" || chp.NomE.value=="" || chp.PrenE.value=="" || chp.AdrE.value=="" || chp.ViE.value=="" || chp.TelE.value==""  || chp.emailE.value=="")
       {
          alert("Remplir tous les champs SVP!");
          chp.CodE.focus();
          changeBackgroundColor(document.clientform2.CodE);
          return false;
       }
       else
       {
          if (isNaN(chp.TelE.value))
          {
             alert("Numero Invalide!");
             chp.TelE.focus();
             changeBackgroundColor(document.clientform2.TelE);
             return false;
          }
          else
          {
             document.clientform2.action="Enseignant.php?mode=add";
             document.clientform2.submit();
             return true;
          }
       }
    }
    </script>
    <table border="0" cellpadding="5" cellspacing="0">
    	<tr>
    		<td colspan="3" class="gray_banner">Enseignant ou futurs enseignants</td>
    	</tr>
    	<tr>
    		<td width="40%" valign="top" class="bold_large" height="380">
    		D&eacute;ja membre ?<br /><br /><br /><br />
    		<!-- formulaire identification -->
    		<form name="clientform" method="post" action="index.php?page=best.htm">
    			<font color="#FF3300">Veuillez saisir votre code de sécurité : </font><br />
    			<input type="text" name="Code">
    			<br /><br />
            	<input type="button" value="Identifiez-vous" onClick="verify();">
    		</form>
    		</td>
    		<td style="width: 1px; background-color: gray" height="380"></td>
    		<td style="width: 70%" class="bold_large" valign="top" height="380">
    		Nouveau ? Inscrivez-vous :<br /><br /><br /><br />
    		<!-- formulaire nouveaux membres -->
    		<form name="clientform2" method="post" action="index.php?page=best.htm"> 
    			<table border="0" width="100%">
    			<tr><td class="bold_right">Code Enseignant</td>
    				<td><input type="text" name="CodE" size="20" maxlength="20"></td>
    			</tr>
    			<tr><td class="bold_right">Nom</td>
    				<td><input type="text" name="NomE" size="20" maxlength="20"></td>
    			</tr>
    			<tr><td class="bold_right">Prenom</td>
    				<td><input type="text" name="PrenE" size="20" maxlength="20"></td></tr>
    			<tr><td class="bold_right">Adresse</td>
    				<td><input type="text" name="AdrE" size="20" maxlength="20"></td></tr>
    			<tr><td class="bold_right">Ville</td>
    				<td><input type="text" name="ViE" size="20" maxlength="20"></td></tr>
    			<tr><td class="bold_right">Telephone</td>
    				<td><input type="text" name="TelE" size="15" maxlength="20"></td></tr>
    			<tr><td class="bold_right">Adresse Email</td>
    				<td><input type="text" name="emailE" size="55" maxlength="67"></td></tr>
    			<tr><td class="bold_right">   
    				&nbsp;</td>
    				<td><br /><input type="button" value="Enregistrez-vous" onClick="ajout();" ></td></tr>
    			</table>
    		</form>
    		</td>
    	</tr>
    	<tr><td colspan="3" style="background-color: gray">&nbsp;</td></tr>
    </table>
    <div style="text-align: center; font-size: .8em">
    Nous appr&eacute;cierions vos commentaires et suggestions. Vous pouvez
    les adresser a <a href="mailto:@gmail.com">X@gmail.com</a></div>
    Ca fonctionne NICKEL, grace a jsd03
    (moi, je ne touche pas une bille en javascript !)

  12. #12
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par lilia_dream Voir le message
    je voudrais colorer toutes les champs de mon formulaire
    1- quelle couleur ?
    2- Tu veux pour TOUS les formulaires en général ou seulement sur cette page ?

    pour TOUS les formulaires : ajouter dans les css
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    input {
      border: 1px solid #026237;
      background-color: #2EC739; /* fond vert, comme espacepro */
      font: 1em Verdana, "Bitstream Vera Sans", "Lucida Grande", sans-serif;
      font-weight: Bold;
       /*( color: white; )*/
    }

  13. #13
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut
    Merci jreaux62

    j'ai mal expliquee l'objectif

    car la question c'etait pour la fonction javascript ,je m'explique alors quand l'enseignant vient rensigner le formulaire il y a une fonction javascript de verification a pour but de verifier si les champs sont remplis ou non le cas ou l'enseignant oublie de remplir une champ une alert apparaitre et le champ devient colorer mais pour l'instant ca marche juste pour le premier champ

    je veux colorer toutes les champs a travers la fonction js quand il oublie de remplir un champ

    toute mes execuses

  14. #14
    Invité
    Invité(e)
    Par défaut
    Dans ce cas, modifie les scripts dans Best.htm :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    <script type="text/javascript">
     
    function changeBackgroundColor(elemnt,couleur)
    {
       if (elemnt) { elemnt.style.backgroundColor = couleur; }
       return;
    }
     
    function verify()
    {
       tt = document.forms['clientform'];
       if (tt.Code.value=="")
       {
          alert("Saisir Votre Code SVP!");
          tt.Code.focus();
          changeBackgroundColor(document.clientform.Code);
          return false;
       } else {
          document.clientform.action="Enseignant.php?mode=control";
          document.clientform.submit();
          return true;
       }
    }
     
    function ajout()
    {
       chp = document.forms['clientform2'];
       changeBackgroundColor(document.clientform2.CodE,'white');
       changeBackgroundColor(document.clientform2.NomE,'white');
       changeBackgroundColor(document.clientform2.PrenE,'white');
       changeBackgroundColor(document.clientform2.AdrE,'white');
       changeBackgroundColor(document.clientform2.ViE,'white');
       changeBackgroundColor(document.clientform2.TelE,'white');
       changeBackgroundColor(document.clientform2.emailE,'white');
     
       if (chp.CodE.value=="" || chp.NomE.value=="" || chp.PrenE.value=="" || chp.AdrE.value=="" || chp.ViE.value=="" || chp.TelE.value==""  || chp.emailE.value=="")
       {
          alert("Remplir tous les champs SVP!");
          if (chp.CodE.value=="") { chp.CodE.focus(); changeBackgroundColor(document.clientform2.CodE,'yellow'); }
          else if (chp.NomE.value=="") { chp.NomE.focus(); changeBackgroundColor(document.clientform2.NomE,'yellow'); }
          else if (chp.PrenE.value=="") { chp.PrenE.focus(); changeBackgroundColor(document.clientform2.PrenE,'yellow'); }
          else if (chp.AdrE.value=="") { chp.AdrE.focus(); changeBackgroundColor(document.clientform2.AdrE,'yellow'); }
          else if (chp.ViE.value=="") { chp.ViE.focus(); changeBackgroundColor(document.clientform2.ViE,'yellow'); }
          else if (chp.TelE.value=="") { chp.TelE.focus(); changeBackgroundColor(document.clientform2.TelE,'yellow'); }
          else if (chp.emailE.value=="") { chp.emailE.focus(); changeBackgroundColor(document.clientform2.emailE,'yellow'); }
          return false;
       } else {
          if (isNaN(chp.TelE.value))
          {
             alert("Numero Invalide!");
             chp.TelE.focus();
             changeBackgroundColor(document.clientform2.TelE);
             return false;
          }
          else
          {
             document.clientform2.action="Enseignant.php?mode=add";
             document.clientform2.submit();
             return true;
          }
       }
    }
    </script>

  15. #15
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut


    jreaux62

    Merci beaucoup de tout mon coeur

    Merci encore

  16. #16
    Invité
    Invité(e)
    Par défaut
    J'ai modifié les scripts changeBackgroundColor(elemnt,couleur) et ajout() :
    ENCORE MIEUX !!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    <script type="text/javascript">
     
    function changeBackgroundColor(elemnt,couleur)
    {
       if (elemnt) { elemnt.style.backgroundColor = couleur; }
       return;
    }
     
    function verify()
    {
       tt = document.forms['clientform'];
       if (tt.Code.value=="")
       {
          alert("Saisir Votre Code SVP!");
          tt.Code.focus();
          changeBackgroundColor(document.clientform.Code);
          return false;
       } else {
          document.clientform.action="Enseignant.php?mode=control";
          document.clientform.submit();
          return true;
       }
    }
     
    function ajout()
    {
       chp = document.forms['clientform2'];
       changeBackgroundColor(document.clientform2.CodE,'white');
       changeBackgroundColor(document.clientform2.NomE,'white');
       changeBackgroundColor(document.clientform2.PrenE,'white');
       changeBackgroundColor(document.clientform2.AdrE,'white');
       changeBackgroundColor(document.clientform2.ViE,'white');
       changeBackgroundColor(document.clientform2.TelE,'white');
       changeBackgroundColor(document.clientform2.emailE,'white');
     
       if (chp.CodE.value=="" || chp.NomE.value=="" || chp.PrenE.value=="" || chp.AdrE.value=="" || chp.ViE.value=="" || chp.TelE.value==""  || chp.emailE.value=="")
       {
          alert("Remplir tous les champs SVP!");
          if (chp.CodE.value=="") { chp.CodE.focus(); changeBackgroundColor(document.clientform2.CodE,'yellow'); }
          else if (chp.NomE.value=="") { chp.NomE.focus(); changeBackgroundColor(document.clientform2.NomE,'yellow'); }
          else if (chp.PrenE.value=="") { chp.PrenE.focus(); changeBackgroundColor(document.clientform2.PrenE,'yellow'); }
          else if (chp.AdrE.value=="") { chp.AdrE.focus(); changeBackgroundColor(document.clientform2.AdrE,'yellow'); }
          else if (chp.ViE.value=="") { chp.ViE.focus(); changeBackgroundColor(document.clientform2.ViE,'yellow'); }
          else if (chp.TelE.value=="") { chp.TelE.focus(); changeBackgroundColor(document.clientform2.TelE,'yellow'); }
          else if (chp.emailE.value=="") { chp.emailE.focus(); changeBackgroundColor(document.clientform2.emailE,'yellow'); }
          return false;
       } else {
          if (isNaN(chp.TelE.value))
          {
             alert("Numero Invalide!");
             chp.TelE.focus();
             changeBackgroundColor(document.clientform2.TelE);
             return false;
          }
          else
          {
             document.clientform2.action="Enseignant.php?mode=add";
             document.clientform2.submit();
             return true;
          }
       }
    }
    </script>

  17. #17
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut

    Merci jreaux vous etes trop serviable

    Merci Beaucoup ca marche nikle


  18. #18
    Invité
    Invité(e)
    Par défaut
    Et en ajoutant une fonction pour VERIFIER LE MAIL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    <script type="text/javascript">
     
    function changeBackgroundColor(elemnt,couleur)
    {
       if (elemnt) { elemnt.style.backgroundColor = couleur; }
       return;
    }
     
    function verify()
    {
       tt = document.forms['clientform'];
       if (tt.Code.value=="")
       {
          alert("Saisir Votre Code SVP!");
          tt.Code.focus();
          changeBackgroundColor(document.clientform.Code);
          return false;
       } else {
          document.clientform.action="Enseignant.php?mode=control";
          document.clientform.submit();
          return true;
       }
    }
     
    function checkmail(email) {
       var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,5}$/
       if(reg.exec(email)==null) { return false; }
       else { return true; }
    }
    function ajout()
    {
       chp = document.forms['clientform2'];
       changeBackgroundColor(document.clientform2.CodE,'white');
       changeBackgroundColor(document.clientform2.NomE,'white');
       changeBackgroundColor(document.clientform2.PrenE,'white');
       changeBackgroundColor(document.clientform2.AdrE,'white');
       changeBackgroundColor(document.clientform2.ViE,'white');
       changeBackgroundColor(document.clientform2.TelE,'white');
       changeBackgroundColor(document.clientform2.emailE,'white');
     
       if (chp.CodE.value=="" || chp.NomE.value=="" || chp.PrenE.value=="" || chp.AdrE.value=="" || chp.ViE.value=="" || chp.TelE.value==""  || chp.emailE.value=="")
       {
          alert("Remplir tous les champs SVP!");
          if (chp.CodE.value=="") { chp.CodE.focus(); changeBackgroundColor(document.clientform2.CodE,'yellow'); }
          else if (chp.NomE.value=="") { chp.NomE.focus(); changeBackgroundColor(document.clientform2.NomE,'yellow'); }
          else if (chp.PrenE.value=="") { chp.PrenE.focus(); changeBackgroundColor(document.clientform2.PrenE,'yellow'); }
          else if (chp.AdrE.value=="") { chp.AdrE.focus(); changeBackgroundColor(document.clientform2.AdrE,'yellow'); }
          else if (chp.ViE.value=="") { chp.ViE.focus(); changeBackgroundColor(document.clientform2.ViE,'yellow'); }
          else if (chp.TelE.value=="") { chp.TelE.focus(); changeBackgroundColor(document.clientform2.TelE,'yellow'); }
          else if (chp.emailE.value=="") { chp.emailE.focus(); changeBackgroundColor(document.clientform2.emailE,'yellow'); }
          return false;
       } else {
          if (isNaN(chp.TelE.value))
          {
             alert("Numero Invalide!");
             changeBackgroundColor(document.clientform2.TelE,'yellow');
             chp.TelE.focus();
             return false;
          }
          else if (!checkmail(chp.emailE.value))
          {
             alert("E-mail Invalide!");
             changeBackgroundColor(document.clientform2.emailE,'yellow');
             chp.emailE.focus();
             return false;
          }
          else
          {
             document.clientform2.action="Enseignant.php?mode=add";
             document.clientform2.submit();
             return true;
          }
       }
    }
    </script>

  19. #19
    Membre du Club Avatar de lilia_dream
    Inscrit en
    Mars 2009
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 267
    Points : 43
    Points
    43
    Par défaut
    Super !! Ça fonctionne !!

    Un grand merci à toi jreaux62 !




+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Appel de fonction javascript
    Par lepierre dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 04/11/2004, 14h28
  2. Réponses: 5
    Dernier message: 13/08/2004, 15h40
  3. Réponses: 4
    Dernier message: 02/06/2004, 16h35
  4. Réponses: 11
    Dernier message: 10/05/2004, 10h49
  5. appel xmlservice via fonction javascript
    Par pram dans le forum XMLRAD
    Réponses: 2
    Dernier message: 06/05/2003, 14h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo