Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1677 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  document.forms[0].submit() ne marche pas

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

document.forms[0].submit() ne marche pas

n°1320748
TheDarksha​dow
only god can judge me!!!
Posté le 08-03-2006 à 10:12:29  profilanswer
 

bonjour je n'arrive pas à faire le submit toute béte de mon formulaire.
sachant que mon formulaire se présente sous la forme: <form name="form_article" action="tst.php" method="post">
le code javascript correspondant est:
 
window.document.forms[0].submit();
document.forms[0].submit();
document.form_article.submit();
 
aucune de ces combinaisons ne marche!
 
il me genere le message suivent sous Firefox: document.form[0].submit is not a function
 
je vous remercie d'av@nce.

mood
Publicité
Posté le 08-03-2006 à 10:12:29  profilanswer
 

n°1320761
benamoubea​ch
tivuplai
Posté le 08-03-2006 à 10:21:03  profilanswer
 

l'attribut name d'une form n'est plus valide W3C . Utilise id
<form id="form_article" action="tst.php" method="post">
 
 
document.getElementById('form_article').submit();  
 
voila :)

n°1320827
TheDarksha​dow
only god can judge me!!!
Posté le 08-03-2006 à 11:33:51  profilanswer
 

Je te remercie j'ai suivi tes conseilles.
 
d'apres le modéle W3C
 
<form id="formArticle" method="post" action="tst.php">
 
j'ai éffectuer les changements càd j'ai mits  
 
document.getElementById('formArticle').submit();  
 
à la place de document.formArticle.submit();
 
Mais il me renvoie toujour l'erreur: document.getElementById('formArticle').submit  is not a function.

n°1320887
gatsu35
Blablaté par Harko
Posté le 08-03-2006 à 13:34:12  profilanswer
 

tu peux nous donner le code HTML de ton form ?  
à Tout hasard tu as du appeler ton bouton d'envoi submit


Message édité par gatsu35 le 08-03-2006 à 13:34:22
n°1320903
TheDarksha​dow
only god can judge me!!!
Posté le 08-03-2006 à 14:01:19  profilanswer
 

Le code se presente comme suit
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans nom</title>
<link href="../css/css_mozz.css" rel="stylesheet" media="screen" />
<script src="../js/fanof_js.js"></script>
</head>
<body>
<form id="formArticle" method="post" action="test.php">
<table class="tabcontnu">
<tr>
<td align="right" id="titre01">Titre</td>
<td><input name="titre" type="text" id="titre"  /></td>
</tr>
<tr>
<td align="right" valign="top" id="descript">Description</td>
<td><textarea name="description" rows="5" id="description" >Max 255 caract&eacute;res</textarea></td>
</tr>
<tr>
<td align="right" valign="top" id="article01">Article</td>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#DAD7D0">
<tr>
<td><a href="#" ><img src="../img/psd_menu_02.gif" alt="Enrégistrer" name="Image20" width="22" height="24" border="0" onClick="format_text('saveAs')"></a><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image20','','../img/psd_menu_01_over.gif',1)"></a></td>
<td><a href="#" ><img src="../img/psd_menu_03.gif" alt="Envoyer article" name="Image21" width="24" height="24" border="0" ></a></td>
<td><a href="preview.php" target="preview" ><img src="../img/psd_menu_05.gif" alt="Imprimer" name="Image22" width="26" height="24" border="0" onClick="javascript: window.frames['article'].print();"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_06.gif" alt="Apérçu" name="Image23" width="25" height="24" border="0" onClick="previewer()"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_08.gif" alt="Couper" name="Image26" width="22" height="24" border="0"  onClick="format_text('Cut')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_09.gif" alt="Copier" name="Image27" width="26" height="24" border="0"  onClick="format_text('Copy')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_10.gif" alt="Coller" name="Image28" width="27" height="24" border="0"  onClick="format_text('Paste')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_11.gif" alt="Annuler frappe" name="Image29" width="23" height="24" border="0" onClick="format_text('Undo')" ></a> </td>
            <td>
   <select name="police" id="selectfont" onChange="format_text('FontName', false, this.value)">
   <option value="Font">Police du text</option>
              <option value="arial">Arial</option>
              <option value="arial narrow">Arial narrow</option>
              <option value="georgia">Georgia</option>
              <option value="helvetica">Helvetica</option>
              <option value="times New Roman">Times New Roman</option>
              <option value="verdana">Verdana</option>
            </select></td>
            <td>
              <select name="taille" id="taille" onChange="format_text('FontSize', false, this.value )" >
    <option>Taille</option>
                <option value="1">9</option>
                <option value="2">10</option>
                <option value="3">12</option>
                <option value="4">14</option>
                <option value="5">16</option>
                <option value="6">18</option>
              </select></td>
            <td><a href="#" ><img src="../img/psd_menu_13.gif" alt="Ajouter un lien Hypertext" name="Image30" width="30" height="24" border="0"  onClick="getLink('createlink', '', links); "></a></td>
            <td><a href="#" ><img src="../img/psd_menu_19.gif" alt="Gras" name="Image31" width="25" height="24" border="0" onClick="format_text('Bold')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_20.gif" alt="Italic" name="Image32" width="24" height="24" border="0" onClick="format_text('Italic')"></a></td>
            <td><a href="#"><img src="../img/psd_menu_21.gif" alt="Souligner" name="Image33" width="27" height="24" border="0" onClick="format_text('Underline')"></a></td>
            <td><a href="#" ><img src="../img/menu_psd_003.gif" alt="Aligner à gauche" name="Image34" width="24" height="25" border="0" onClick="format_text('justifyLeft')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_23.gif" alt="Centrer" name="Image35" width="20" height="24" border="0" onClick="format_text('justifyCenter')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_24.gif" alt="Aligner à droite" name="Image36" width="22" height="24" border="0" onClick="format_text('justifyRight')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_25.gif" alt="Justifier" name="Image37" width="26" height="24" border="0" onClick="format_text('justifyFull')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_31.gif" alt="Retrait" name="Image38" width="22" height="24" border="0" onClick="format_text('outdent')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_32.gif" alt="Indenter" name="Image39" width="27" height="24" border="0" onClick="format_text('indent')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_34.gif" alt="colorier le text" name="Image25" width="25" height="24" border="0" onClick="format_text('ForeColor', '', '#CC0000')"></a></td>
            <td><a href="#" ><img src="../img/psd_menu_37.gif" alt="Revenir au noir" name="Image40" width="25" height="24" border="0" onClick="format_text('ForeColor', '', '#000000')"></a> </td>
            <td><a href="#" ><img src="../img/psd_menu_36.gif" alt="Souligner arrier plan" name="Image24" width="23" height="24" border="0" onClick="format_text('backColor', '', '#D1EE5F')"></a></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><iframe name="article" id="article" frameborder="0"></iframe></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="right" id="categ">Cat&eacute;gorie</td>
 
    <td>
 <select name="id_categorie" id="co">
  <option value="" selected >Choisissez</option>
 
   <option value="" >test</option>
 
  </select>
 <input type="hidden" name="htmlCode"></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>
 <input type="hidden" name="formated_text" id="formated_text" />
 <input type="button" name="cancel" value="Annuler" id="cancel"  />    
 <input type="button" name="submit" value="Envoyer" id="submit" onClick="submitForm()"/></td>
  </tr>
</table>
</form>
 
</body>
</html>
 
 
le Fichie JS relatif est comme suit:  
 
 
function submitForm(){
document.getElementById('formArticle').submit();  
}

n°1321035
gatsu35
Blablaté par Harko
Posté le 08-03-2006 à 16:03:13  profilanswer
 

<input type="button" name="submit" value="Envoyer" id="submit" onClick="submitForm()"/></
c'est bien ce que je disait tu l'as appelé submit ton bouton c'est normal que ce ne marche pas
et pourquoi appeler une fonction JS pour submit un form alors que ce code suivant aurait largement suffit:  
 <input type="submit" name="cancel" value="Annuler" id="cancel"  />      
 <input type="submit" name="action" value="Envoyer" id="submit" />
 
et personnellement vu ta connaissance  de l'HTML proche du néant, tu peux repasser en HTML transitionnal dans ton doctype et eviter le XHTML qui n'est pas fait pour toi vu le caca que tu nous ponds


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  document.forms[0].submit() ne marche pas

 

Sujets relatifs
un hover qui ne marche pas sur ieSpécifier la langue d'un document
XSLT, NameSpace et Requete XPath ca marche pasRequete http via un document excel
[Word] Un document Word multilangue ?sa ne marche pas !!!
Plusieurs Submit dans un meme formCe cookie ne marche pas sur mon ordi !!
impression de document html+css 
Plus de sujets relatifs à : document.forms[0].submit() ne marche pas


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR