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 :

Erreur sur un form


Sujet :

JavaScript

  1. #1
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    145
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 145
    Points : 64
    Points
    64
    Par défaut Erreur sur un form
    Bonjour,

    Dans un code JSP, j'ai incorporer du code javascript, ce dernier marchait merveilleusement bien, jusqu'au jour où je rencontre cette erreur :

    'document.DataForm.elements' is null or not an object

    sachant que mon form en question est 'DataForm', et que je ne lui ai pas changé de nom, je n'ai même pas retouché mon script javascript,

    Quand je regarde le source de ma page HTML, à la ligne en question et à la position du caractère en question, je retrouve mon code javascript, tel qu'il est, mais rien de plus,

    Qu'est-ce que cela peut-il être ???

    Merci d'avance,

    PS: Je mets a la fin de ce message ma fonction en question , peut être que ça va vous orienter

    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
    function Validation()
            {
     
    			     var exp_etud  		=new RegExp("f_etud","g");
    				 var exp_stat  		=new RegExp("f_stat","g");
    				 var exp_prev_tot 	=new RegExp("f_prev_tot_etud","g");
    				 var exp_pgm  		=new RegExp("f_pgm","g");
    				 var exp_moi_km 	=new RegExp("f_realiz_moi_km","g");
    				 var exp_moi_vp	  	=new RegExp("f_realiz_moi_vp","g");
    				 var exp_point	  	=new RegExp(",","g");
    				 var space          =new RegExp(" ","g");
                     var formElts = document.DataForm.elements;
    				 var msg="";
                     erreur = "_____________________________\nFormat erroné : \n";
     
     
     
    				 var x=0;
                     while ( x < formElts.length ) {
     
                                        if(formElts[x].type == 'select-one' )
    									{
    										if (exp_etud.test(formElts[x].name)){
    												 if(formElts[x].value=="" || formElts[x].value==" " )
    													{
    													msg+="- L'etude sismique est un champ obligatoire !! \n";
    													break; 
    													}
    													}
    										if (exp_stat.test(formElts[x].name)){
    												 if(formElts[x].value=="UNKNOWN"  || formElts[x].value==" ")
    													{msg+="- Le statut est un champ obligatoire !! \n";
    													break;} }
     
    									}
     
    					 if(formElts[x].type == 'text' )
    						{	//1						
     
    						if (exp_prev_tot.test(formElts[x].name))
    						   {   //2  
    							if(parseFloat(formElts[x].value)<0 || isNaN(parseFloat(formElts[x].value.replace (exp_point,"."))) || space.test(formElts[x].value)) 
        						  {//3
    							   msg+="- Prévision total etude  : "+formElts[x].value +"\n";
    							   } //3
    						    else{//4
    							     formElts[x].value=formElts[x].value.replace (exp_point,".");
    								 }//4
    		    				} //2
     
    						if (exp_pgm.test(formElts[x].name))
    						   { //5
                                if(parseFloat(formElts[x].value)<0 || isNaN(parseFloat(formElts[x].value.replace (exp_point,"."))) || space.test(formElts[x].value))
    							  { //6
                                   msg+="- PGM : "+formElts[x].value +"\n";
                                   } //6
    							 else{formElts[x].value=formElts[x].value.replace (exp_point,".");}
    							 } //5
     
    						if (exp_moi_km.test(formElts[x].name))
    						   { //7
                                if(parseFloat(formElts[x].value)<0 || isNaN(parseFloat(formElts[x].value.replace (exp_point,"."))) || space.test(formElts[x].value))
    							  { //8
                                   msg+="- Réalisation du moi(Km) :"+formElts[x].value +"\n";
                                   } //8
    							  else{formElts[x].value=formElts[x].value.replace (exp_point,".");}
    							 }//7
     
    						if (exp_moi_vp.test(formElts[x].name))
    						   {//9
                               if(isNaN(formElts[x].value))
    						      {//10
                                   msg+="- Réalisation du moi(VP) :"+formElts[x].value +"\n";
                                   }//10
    							}//9
     
                                       }//1
     
    					x++			
                     }
     
                    if (msg!="" ) 
                    {           
                               alert(erreur+msg+"_____________________________\n\n");
                    }
    				else 
    				{
    				document.DataForm.submit();
    				}
     
        }

  2. #2
    Expert confirmé
    Avatar de javatwister
    Homme Profil pro
    danseur
    Inscrit en
    Août 2003
    Messages
    3 681
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : danseur

    Informations forums :
    Inscription : Août 2003
    Messages : 3 681
    Points : 5 221
    Points
    5 221
    Par défaut
    tu peux donner le code formulaire aussi, et notamment l'appel de validation()?

  3. #3
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    145
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 145
    Points : 64
    Points
    64
    Par défaut
    Voici le code de mon form:

    Code HTML : 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
    <FORM method="post"  name="DataForm" action="FOR_1812_ValidationInputFormSIS2DMen.jsp">
     
    	<table width="90%" height="100" border="0"  align=center id="table1"  >
    		<tr align="left" class="pagesSubTab"> 		
    			<!--Ligne des Entetes des colonnes-->
    			<td  align='center' width="2%" >N°:</td>
    			<td width="6%"  align='center' >Etudes 2D *</td>
    			<td  align='center' width="5%" >Statut *</td>	 			
    			<td  align='center' width="6%" >Entreprise de service</td>										
    			<td  align='center' width="6%" >Date d&eacute;but de travaux</td>	
    			<td  align='center' width="6%" >Date fin de<br>
    			   travaux</td>	
    			<td width="5%"  align='center' >Pr&eacute;vision totale &eacute;tude (KM) </td>
    			<td width="4%"  align='center' >PGM (Km2)</td>
    			<td width="6%"  align='center' >R&eacute;alisation du mois<br> 
    			(Km2)</td>
    			<td width="6%"  align='center' >R&eacute;alisation du mois<br> (VP)</td>
     
    		</tr>
    		<tr bgcolor="#A0A0A4">
     
    		</tr>
     
    	<%      if (compt_ligne==0) {compt_ligne=1;}
                    int line=1;                                                     //Compteur pr l'affichage du numero de ligne sur le rapport 
                    for (i=0; i<compt_ligne; i++)                   //starting of the loop to create dynamically the RETRIEVED lines from DB
                    {
                    
                    //{     ----------Debut de l'affichage en boucle du tableau----------*/ 
                    
                    %>	
    		<tr class="<%=contentCell[(line%2)]%>">
    			<td  align='center' width="2%"><%=line++%></td>
    			<td align='center' >
     
    			<%if (compt_ligne!=1){%>
    			<input name="f_etude_<%=i%>"  readonly="true"size="18"type=text value="<%=etude_tab[i]%>">
    			<%} else {%>
    		  	<select id="f_etude_<%=i%>" name="f_etude_<%=i%>" >
    	 		<option <%if("null".equals(etude_tab[i])){%> selected <%}%> value=""style="background-color:#FFDFAA">Etude sismique</option>
    			<%for (int j=0; j<cptEtude2DArray; j++){%>
    	 		<option <%if(etude2DArray[j].equals(etude_tab[i])){%> selected <%}%> value="<%=etude2DArray[j]%>"><%=etude2DArray[j]%>
    			</option>
    	 		<%}%>
    		  </select>
    		<%}%>
     
     
    			</td>
     
     
    			<td  align='center' >
    			<select id="f_stat_<%=i%>" name="f_stat_<%=i%>"  >
    	 			<option <%if("UNKNOWN".equals(statut_tab[i])){%> selected <%}%> value="UNKNOWN"style="background-color:#FFDFAA">Statut</option>
    	 			<option <%if("Prevu".equals(statut_tab[i])){%> selected <%}%> value="Prevu">Prevu</option>
    				<option <%if("En cours".equals(statut_tab[i])){%> selected <%}%> value="En cours">En cours</option>
    				<option <%if("Termine".equals(statut_tab[i])){%> selected <%}%> value="Termine">Termine</option>
    	 	    </select>
    			</td>
     
     
     
    			<td  align='center' >
     
     
    			<select id="f_entrepreneur_<%=i%>" name="f_entrepreneur_<%=i%>"   >
    				<option <%if("null".equals(entrepreneur_tab[i])){%> selected <%}%> value=""style="background-color:#FFDFAA">Entrepreneur</option>
    	 			<%for (int j=0; j<cptEntrpArray; j++){%>
    	 			<option <%if(entrpArray[j].equals(entrepreneur_tab[i])){%> selected <%}%> value="<%=entrpArray[j]%>"><%=entrpArray[j]%>
    				</option>
    	 			<%}%>
    	 	    </select>
     
    			</td>			
    			<td  align='center' width="5%">
    			<%
                            String datDDT="";
                            if (!dat_deb_trav_tab[i].equals(" ")){datDDT =formatDate(dat_deb_trav_tab[i].toString(),"yyyy-mm-dd","dd/mm/yyyy");}
                            %>
    		<input name="f_dat_deb_trav_<%=i%>" size="10"type=text value="<%=datDDT%>" readonly="true" onChange="datecontrol();">
    			<img border="0" id="_btn_calendar1<%=i%>" src ="/dp/pages/forage/JSCalendar/img.gif"  onmouseover="this.style.background='red';" onMouseOut="this.style.background='white';">
     
    		  <script type="text/javascript">
                            Calendar.setup({
                                    inputField     :    "f_dat_deb_trav_<%=i%>",      // id of the input field
                                    ifFormat       :    "%d/%m/%Y",       // format of the input field
                                    showsTime      :    false,            // will display a time selector
                                    button         :    "_btn_calendar1<%=i%>",   // trigger for the calendar (button ID)
                                    singleClick    :    true,           // double-click mode
                                    align          :    "Tl",
                                    step           :    1             // show all years in drop-down boxes (instead of every other year as default)
                            });
                            </script>
    			</td>
    			<td  align='center' width="5%">
    			<%
                            String datDFT="";
                            if (!dat_fin_trav_tab[i].equals(" ")){datDFT =formatDate(dat_fin_trav_tab[i].toString(),"yyyy-mm-dd","dd/mm/yyyy");}
                            %>
    			<input name="f_dat_fin_trav_<%=i%>" size="10"type=text value="<%=datDFT%>" readonly="true" onChange="datecontrol();">
    			<img border="0" id="_btn_calendar3<%=i%>" src ="/dp/pages/forage/JSCalendar/img.gif"  onmouseover="this.style.background='red';" onMouseOut="this.style.background='white';">
     
    		  <script type="text/javascript">
                            Calendar.setup({
                                    inputField     :    "f_dat_fin_trav_<%=i%>",      // id of the input field
                                    ifFormat       :    "%d/%m/%Y",       // format of the input field
                                    showsTime      :    false,            // will display a time selector
                                    button         :    "_btn_calendar3<%=i%>",   // trigger for the calendar (button ID)
                                    singleClick    :    true,           // double-click mode
                                    align          :    "T2",
                                    step           :    1             // show all years in drop-down boxes (instead of every other year as default)
                            });
                            </script>
    			</td>
     
    			<td  align='center' >
     
    <input  maxlength="20" name="f_prev_tot_etud_<%=i%>" size="7" type=text value="<%=formatDecimal(prev_tot_etud_tab[i],dcfs, decimalFormat9, "")%>">
    	        </td>
     
    			<td  align='center' >
    			<input maxlength="20" NAME="f_pgm_<%=i%>" size="7"type=text value="<%=formatDecimal(pgm_tab[i],dcfs, decimalFormat9, "")%>">
    			</td>
     
    			<td  align='center' >
    			<input maxlength="20" name="f_realiz_moi_km_<%=i%>"size="7"type=text  value="<%=formatDecimal(realiz_moi_km_tab[i],dcfs, decimalFormat9, "")%>">
    			</td>
     
    			<td  align='center' >
    			<input maxlength="20" NAME="f_realiz_moi_vp_<%=i%>" size="7"type=text value="<%=realiz_moi_vp_tab[i]%>">
    			</td>
     
    		</tr> 
     
    	<%}    //----------------------End of the loop--------------------------------- %>	
     
    	<!----------------send the number of lignes parameter to validation form-->
    	<input type="hidden" name="f_compt_ligne" value="<%=compt_ligne%>">   </input> 
     
       </table>
          <table width="90%"  border="0"  align="center" id="table2"  >  
     	  	<tr align="left">
    			<td align="left">
    			<a href="#" onClick="AjouterLigne();"><img border=1 src="/dp/pages/common/images/addQueryRow.gif" align="left"></a>
    			</td>
     
    	 	</tr>
     	</table>
    	<br>
    	<br>
    	<table width='450px' border=0 align="center" class="pagesSubTab">
    		<tr>
    			<td width="" align="center" class="pagesSubTab">
    			  <INPUT TYPE="BUTTON" NAME="bt_validation" VALUE="VALIDER" style="font-family: Arial; font-size: 10px; text-decoration: underline" OnClick="Validation()">
    			<td  width="" align="center" class="pagesSubTab">
    			    <INPUT TYPE="reset" VALUE="ANNULER" style="font-family: Arial; font-size: 10px; text-decoration: underline" >
    	  </tr>
    	</table>
     
    </FORM>

    L'appel de la fonction Validation se fait lors du click sur le boutton valider,

    Merci

  4. #4
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    145
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 145
    Points : 64
    Points
    64
    Par défaut
    Y'a t il un autre moyen que (document.DataForm.elements pour recuperer les elements d'un form ???

  5. #5
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    145
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 145
    Points : 64
    Points
    64
    Par défaut
    c'est bon, j'ai trouver, j'avais mal fermer la balise </FORM>, j'avais ecris <FORM/> a la palce

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

Discussions similaires

  1. Erreur sur RadioButton Form Load
    Par AsyLuM dans le forum VB.NET
    Réponses: 1
    Dernier message: 13/09/2014, 15h24
  2. Erreur sur suppression Record dans SS form
    Par Maxsen dans le forum VBA Access
    Réponses: 4
    Dernier message: 29/02/2008, 21h45
  3. Erreur de propriété sur une forme
    Par Masmeta dans le forum C++Builder
    Réponses: 7
    Dernier message: 29/05/2007, 15h19
  4. [D7] erreur sur Form.Free
    Par jlf dans le forum Delphi
    Réponses: 9
    Dernier message: 01/05/2007, 12h52
  5. [Forms 6i] Capter l'erreur sur Next_Record
    Par Veve44 dans le forum Forms
    Réponses: 7
    Dernier message: 25/04/2006, 12h08

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