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

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Recuperer tout le contenu d'une balise (A L'AIDE :((( )

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Recuperer tout le contenu d'une balise (A L'AIDE :((( )

n°1183579
Gat$
http://www.wowteamfinder.com
Posté le 24-08-2005 à 18:11:58  profilanswer
 

Bonjour,
 
je m'explique.
Voilà un exemple :  
 

<table id="tab">
 <tr>
  <td>bla</td>
  <td>blabla</td>
  <td>blablabla</td>
 </tr>
</table>


 
je voudrais savoir comment faire en JS pour recuperer tous ce qu'il y a a l'interieur de la balise <table></table>.
Donc ceci :  
 

<tr>
  <td>bla</td>
  <td>blabla</td>
  <td>blablabla</td>
 </tr>


 
j'ai bien essayé ceci :  
 

var test;
test=document.getElementById("tab" ).textContent;


 
mais ca passe pas.
Et mes recherche sur google sont infrucuteuse :(
 
Quelqu'un peut-il m'aider ?  
 
Merci d'avance :)
 
 :hello:


Message édité par Gat$ le 25-08-2005 à 13:15:05

---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
mood
Publicité
Posté le 24-08-2005 à 18:11:58  profilanswer
 

n°1183603
olivthill
Posté le 24-08-2005 à 18:28:58  profilanswer
 

Au lieu de TextContent, tu peux essayer innerText ou innerHTML. J'ai testé pour toi l'exemple suivant sous IE 6 :

<html>
<body>
<table id="tab">  
 <tr>  
  <td>bla</td>  
  <td>blabla</td>  
  <td>blablabla</td>  
 </tr>  
</table>
<script language=javascript>
alert(document.getElementById("tab" ).innerText);  
alert(document.getElementById("tab" ).innerHTML);  
</script>
</body>
</html>


Message édité par olivthill le 24-08-2005 à 18:29:34
n°1183641
masklinn
í dag viðrar vel til loftárása
Posté le 24-08-2005 à 19:14:11  profilanswer
 

.innerHTML pour récupérer le tout sous forme de texte, ou bien tu joues avec cloneNode pour récupérer des bouts de DOM


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
n°1183693
Gat$
http://www.wowteamfinder.com
Posté le 24-08-2005 à 20:26:51  profilanswer
 

Bonsoir
 
j'avais testé innerHTML ca avait pas l'air de passer, je vais reessayer avec innerText
 
Merci :)


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1183697
Gat$
http://www.wowteamfinder.com
Posté le 24-08-2005 à 20:32:48  profilanswer
 

Avec InnerText ca retourne undefined
 
tandis que avec interHTML cela fonctionne mais il ajoute des balises au debut et a la fin <tbody> et </tbody> qui apparemment font merdé l'affichage dans mon cas. Enfin je peux parser pour les virer mais c du code en plus.
 
Enfin je le ferai si ya pas d'autre moyen
 
Merci :)


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184168
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 13:13:41  profilanswer
 

BOnjour
 
je fais un reply dans ce topic paske je suis completement desesperé, revolté, enervé, au bout du roulau parce que le JS ca me GAVE !!!!!!!!
 
ceci :  
 
<script language="javascript">
 document.getElementById("tabpanier" ).innerHTML = "test";
</script>
 
Marchais hier parfaitement !
 
Et aujourd'hui sous explorer il me sors une erreur JS de merde pour aucune raison!!!
 
JAVAscript est le language le plus instable que je connaisse, j'en peux plus, je sais plus quoi faire. C amarchais hier sous mozzilla et explorer
et aujourd'hui ca merde sur explorer et pas mozzilla
SANS QUE JE NE CHANGE RIEN !!!!
 
Voici l'erreur retournée :  
 
Erreur: 'document.getElementById(....)' a la valeur Null ou n'est pas un objet.
 
 
FAUX !!!!!!!!! tabpanier est un objet !!!!!!!!!
 
cf :
 
<table id="tabpanier" align="center" class="text" style="width: 100%; font-size: 12px;  border: 1px dashed #000000;"  border="0" cellspacing="0" cellpadding="4">
(...)
</table>
 
 
 
Alors ! :'( :'( :'(  
 
 
SVP que faire pour eviter ce genre d'erreur et de petage de plomb c'est pas la premiere fois que je perd une journée a chercher une erreur de merde dans JS.... j'en ai marre svp aidez moi :(
 
Gat$
 
 


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184190
gatsusat
Posté le 25-08-2005 à 13:47:38  profilanswer
 

c'est toi qui est instable c'est tout
 
colle nous tout le code HTML de ta page, JS et HTML  
 
on verra d'ou vient l'erreur

n°1184201
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 13:59:37  profilanswer
 

Salut
 
non serieux c'est un probleme abérant, je suis tellement enervé que j'arrive pas a exprimer le probleme correctement, il faudrait que qqun se connecte a mon PC via VNC ou quoi, paske j'en peu plus... Enfin bref si tu veux ce code marche dans certains cas et pas dans d'autre... je veux bien coller le code html +js mais ca risque de pas etre tres clair, enfin je me lance :  
 
 
Voila j'ai 2 fichiers js :
 
"misc.js"
"gestion_ventes.js"
 
 
que j'inclu dans ma page comme ceci :
 
<script language="javascript" src="javascript/misc.js"></script>
<script language="javascript" src="javascript/gestion_ventes.js"></script>
 
Et voila le fichier de ma page php ou les scripts JS sont insérés dans le html
 
"formulaire_vente.inc.php"
 
 
Contenu de "misc.js" :

Code :
  1. // Change le texte a l'intérieur d'une balise html
  2. function ChangerTexteBalise(IdBalise, toThis) {
  3. if (document.getElementById) {
  4.  document.getElementById(IdBalise).innerHTML = toThis;
  5. }
  6. else if (document.all) {
  7.  document.all[IdBalise].innerHTML = toThis;
  8. }
  9. }
  10. // Vide une liste
  11. function ViderListe(liste)
  12. {
  13. l=liste.length;
  14. for (i=l; i>=0; i--)
  15. liste.options[i]=null;
  16. }


 
 
 
 
 
Contenu de "gestion_ventes.js" :

Code :
  1. var panier=new Array();
  2. var tab_panier_header_html=new String();
  3. // Met a jour les informations de l'article selectionné
  4. function MajInfosArticle(IdArticle) {
  5. var i;
  6. for(i=0; i<tab_articles.length; i++) {
  7.  if(tab_articles[i]["id_article"]==IdArticle) {
  8.   // ICI CA MARCHE NICKEL !!!!! POURQUOI?    
  9.   ChangerTexteBalise("qt_stock", tab_articles[i]["qt_achete"]-tab_articles[i]["qt_vendu"]);
  10.   ChangerTexteBalise("pu", tab_articles[i]["prix_vente"]+" &euro;" );
  11.   ChangerTexteBalise("description", tab_articles[i]["description"]);
  12.   FillAjoutArticleCmb(tab_articles[i]["qt_achete"]-tab_articles[i]["qt_vendu"]);
  13.   return true;
  14.  }
  15. }
  16. }
  17. // Met a jour la combobox quantité d'article en fonction de la quantité en stock
  18. function FillAjoutArticleCmb(qt) {
  19. var i;
  20. ViderListe(document.frmVente.ajout_qt);
  21. var no_select = new Option("(Choix)", -1, false, false);
  22. document.frmVente.ajout_qt.options[document.frmVente.ajout_qt.length] = no_select;
  23. for(i=0; i < qt; i++) {
  24.  var nouvel_element = new Option(i+1, i+1, false, false);
  25.  document.frmVente.ajout_qt.options[document.frmVente.ajout_qt.length] = nouvel_element;
  26. }
  27. }
  28. // Ajoute une ligne au tableau (id: tab_panier)
  29. function AjouterArticlePanier(IdArticle, qt) {
  30. var html_line;
  31. var i;
  32. // On récupere le header du tableau si ce n'est pas deja fait
  33. if(tab_panier_header_html.length<1) {
  34.  tab_panier_header_html=document.getElementById('tab_panier').innerHTML;
  35.  tab_panier_header_html=tab_panier_header_html.replace("<tbody>", "" );
  36.  tab_panier_header_html=tab_panier_header_html.replace("</tbody>", "" );
  37.  tab_panier_header_html=tab_panier_header_html.replace("<TBODY>", "" );
  38.  tab_panier_header_html=tab_panier_header_html.replace("</TBODY>", "" );
  39. }
  40. // On recherche les infos dans le tableau
  41. for(i=0; i<tab_articles.length; i++) {
  42.  if(tab_articles[i]["id_article"]==IdArticle) { // Si Article trouvé, on ajoute
  43.   // code html de la ligne a ajouter
  44.   //html_line="<tr align=\"left\" valign=\"top\"><td class=\"tab_arrow\">"+tab_articles[i]["id_article"]+"</td><td class=\"tab_arrow\">"+tab_articles[i]["nom_article"]+"</td><td class=\"tab_arrow\">"+qt+"</td><td class=\"tab_arrow\">"+tab_articles[i]["prix_vente"]+" &euro;</td><td class=\"tab_arrow\" style=\"font-weight: bold;\">"+(qt*tab_articles[i]["prix_vente"])+" &euro;</td><td align=\"center\" class=\"tab_arrow\"><img src=\"../../design/btn-supprimer.gif\" width=\"20\" height=\"20\"></td></tr>";
  45.   html_line="test";
  46.   //alert(tab_panier_header_html+html_line);
  47.   // On insere la ligne dans le tableau html
  48.   ChangerTexteBalise("tab_panier", html_line);  // ICI CA MERDE SANS RAISON !!!!!!!!!!
  49.   // On ajoute l'id de l'article au panier
  50.   //panier[panier.length]=IdArticle;
  51.  }
  52. }
  53. }


 
 
 
 
 
Et voila le contenu de la page HTML générée  par le script php :  
 

Code :
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <SCRIPT LANGUAGE="JavaScript">
  5. /* Cette fonction ajoute une option dans la combo ou listbox donnée */
  6. function AjouterOption(libelle, valeur, cible) {
  7.  NewOption=new Option(libelle,valeur);
  8.  cible.options[cible.options.length]=NewOption;
  9. }
  10. </SCRIPT>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  13. <title>Thunder Gym - Site web</title>
  14. <link href="style.css" rel="stylesheet" type="text/css">
  15. </head>
  16. <body>
  17. <table class="main-container" style="width: 992px;" height="100%" border="0" cellspacing="0" cellpadding="0">
  18.   <tr>
  19.     <td width="992" align="center" valign="top">
  20.  <div class="main-banner"></div>
  21.  <div class="menu-fade-container">
  22.   <a style="border-right: 1px solid #FFFFFF; width: 134px;" class="menu-fade1" href="index.php">Pr&eacute;sentation</a>
  23.   <a style="border-right: 1px solid #FFFFFF; width: 134px;" class="menu-fade1" href="disciplines.php">Cours</a>
  24.   <a style="border-right: 1px solid #FFFFFF; width: 133px;" class="menu-fade1" href="accessoires.php">Accesoires</a>
  25.   <a style="border-right: 1px solid #FFFFFF; width: 134px;" class="menu-fade1" href="horaires.php">Horaires</a>
  26.   <a style="border-right: 1px solid #FFFFFF; width: 133px;" class="menu-fade1" href="inscription.php">Inscription</a>
  27.   <a style="border-right: 1px solid #FFFFFF; width: 134px;" class="menu-fade1" href="partenaires.php">Partenaires</a>
  28.   <a style="width: 134px;" class="menu-fade1" href="contact.php">Contact</a>
  29.  </div>
  30.  <div class="text" style="text-align: right; width: 943px; height: 19px; background-image: url(design/separateur1.gif); background-repeat:no-repeat; font-size: 10px; color: #FFFFFF;">
  31.   <div style="padding-top: 3px;">
  32.   Connect&eacute; : <span style="font-weight: bold;">-, -&nbsp;</span> (192.168.0.5)
  33.   </div>
  34.  </div>
  35.  <table width="944"  border="0" cellspacing="0" cellpadding="0">
  36.           <tr>
  37.             <td valign="top" style="text-align: center; width: 268px; height: 400px;">
  38.    <a href="admin.php" class="submenu">&nbsp;&nbsp;&nbsp;<span style="color: #FFBE00; font-weight: vold;">Administration...</span></a><a href="admin.php?s2=gestion_membres" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Membres</a><a href="admin.php?s2=gestion_employes" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Employ&eacute;s</a><a href="admin.php?s2=gestion_cours" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Disciplines</a><a href="admin.php?s2=gestion_ventes" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-close.gif" border="0" alt=""/> Ventes</a><a href="admin.php?s2=gestion_stocks" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Stocks</a><a href="admin.php?s2=config" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-nothing.gif" border="0" alt=""/> Configuration</a><a href="admin.php?s2=loggout" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-nothing.gif" border="0" alt=""/> Se déconnecter</a><br></div>
  39. </td>
  40.             <td valign="top" class="text" style="text-align: left;">
  41.    <div class="section-title">&nbsp;&nbsp;<span style="font-weight: bold;">Administration</span><br>
  42.     </div>
  43.   <div class="text" style="margin: 10px;">
  44. <script language="javascript">var tab_articles=new Array();
  45. tab_articles[0]=new Array();
  46. tab_articles[0]["id_article"]=64;
  47. tab_articles[0]["nom_article"]="AA";
  48. tab_articles[0]["description"]="";
  49. tab_articles[0]["prix_vente"]="1.00";
  50. tab_articles[0]["id_categorie"]="";
  51. tab_articles[0]["nom_cat"]="";
  52. tab_articles[0]["qt_achete"]="0";
  53. tab_articles[0]["qt_vendu"]="0";
  54. tab_articles[1]=new Array();
  55. tab_articles[1]["id_article"]=38;
  56. tab_articles[1]["nom_article"]="CAFE";
  57. tab_articles[1]["description"]="";
  58. tab_articles[1]["prix_vente"]="0.50";
  59. tab_articles[1]["id_categorie"]="";
  60. tab_articles[1]["nom_cat"]="";
  61. tab_articles[1]["qt_achete"]="0";
  62. tab_articles[1]["qt_vendu"]="0";
  63. tab_articles[2]=new Array();
  64. tab_articles[2]["id_article"]=32;
  65. tab_articles[2]["nom_article"]="EAU  50cl";
  66. tab_articles[2]["description"]="";
  67. tab_articles[2]["prix_vente"]="0.50";
  68. tab_articles[2]["id_categorie"]="";
  69. tab_articles[2]["nom_cat"]="";
  70. tab_articles[2]["qt_achete"]="0";
  71. tab_articles[2]["qt_vendu"]="0";
  72. tab_articles[3]=new Array();
  73. tab_articles[3]["id_article"]=27;
  74. tab_articles[3]["nom_article"]="MILK SHAKE maison";
  75. tab_articles[3]["description"]="";
  76. tab_articles[3]["prix_vente"]="1.50";
  77. tab_articles[3]["id_categorie"]="";
  78. tab_articles[3]["nom_cat"]="";
  79. tab_articles[3]["qt_achete"]="0";
  80. tab_articles[3]["qt_vendu"]="0";
  81. tab_articles[4]=new Array();
  82. tab_articles[4]["id_article"]=52;
  83. tab_articles[4]["nom_article"]="PROTEINE +";
  84. tab_articles[4]["description"]="";
  85. tab_articles[4]["prix_vente"]="2.50";
  86. tab_articles[4]["id_categorie"]="";
  87. tab_articles[4]["nom_cat"]="";
  88. tab_articles[4]["qt_achete"]="0";
  89. tab_articles[4]["qt_vendu"]="0";
  90. tab_articles[5]=new Array();
  91. tab_articles[5]["id_article"]=6;
  92. tab_articles[5]["nom_article"]="RED MAX";
  93. tab_articles[5]["description"]="";
  94. tab_articles[5]["prix_vente"]="1.70";
  95. tab_articles[5]["id_categorie"]="";
  96. tab_articles[5]["nom_cat"]="";
  97. tab_articles[5]["qt_achete"]="2";
  98. tab_articles[5]["qt_vendu"]="0";
  99. tab_articles[6]=new Array();
  100. tab_articles[6]["id_article"]=39;
  101. tab_articles[6]["nom_article"]="SODA";
  102. tab_articles[6]["description"]="";
  103. tab_articles[6]["prix_vente"]="1.00";
  104. tab_articles[6]["id_categorie"]="";
  105. tab_articles[6]["nom_cat"]="";
  106. tab_articles[6]["qt_achete"]="0";
  107. tab_articles[6]["qt_vendu"]="0";
  108. </script>
  109. <script language="javascript" src="javascript/misc.js"></script>
  110. <script language="javascript" src="javascript/gestion_ventes.js"></script>
  111. <form name="frmVente" method="post" action="">
  112.   <table align="center" class="text" style="width: 100%; font-size: 12px;  border: 1px dashed #000000;"  border="0" cellspacing="0" cellpadding="0">
  113.     <tr >
  114.       <td colspan="3" class="tab_title" style="border-bottom: 1px dashed #000000;font-weight: bold; text-align: center;">Liste
  115.         des articles</td>
  116.     </tr>
  117.     <tr align="left" valign="top">
  118.       <td class="tab_arrow" style="width: 275px; font-weight: bold; color: #0000FF; padding: 4px;">
  119.         <select class="frm1" id="lst_articles" name="lst_articles" size="10" style="width: 275px;" onChange='javascript:MajInfosArticle(document.getElementById("lst_articles" ).value);'>
  120.           <option value="64">Boissons > AA</option><option value="38">Boissons > CAFE</option><option value="32">Boissons > EAU  50cl</option><option value="27">Boissons > MILK SHAKE maison</option><option value="52">Boissons > PROTEINE +</option><option value="6">Boissons > RED MAX</option><option value="39">Boissons > SODA</option><option value="81">Boissons > SUPER AMINO</option><option value="24">Boissons > SUPER BURNER</option><option value="11">Boissons > SUPER CARBO</option><option value="65">Boissons > TEST</option><option value="35">Matériels > BANDAGE compétition velcro</option><option value="72">Matériels > CASQUE Tae kwon do haute protection</option><option value="29">Matériels > CHEVILLERES</option><option value="33">Matériels > COQUILLE avec suspensoir</option><option value="47">Matériels > CORDE câble</option><option value="75">Matériels > CORDE speed noire</option><option value="82">Matériels > GANTS BOXE Go n Get Jab</option><option value="61">Matériels > GANTS BOXE muay velcro taille 14</option><option value="45">Matériels > GANTS BOXE top en vinyl</option><option value="78">Matériels > GANTS FITNESS ciur chromé</option><option value="59">Matériels > GANTS FITNESS cuir long strap</option><option value="49">Matériels > GANTS SAC best angels</option><option value="58">Matériels > PANTALON FULL satin avec liseré</option><option value="15">Matériels > PROTEGE DENTS couleurs en boîte</option><option value="28">Matériels > PROTEGE DENTS professionnel avec pâte</option><option value="8">Matériels > PROTEGE DENTS simple junior</option><option value="10">Matériels > PROTEGE DENTS simple senior</option><option value="5">Matériels > PROTEGE TIBIAS</option><option value="83">Matériels > PROTEGE TIBIAS et PIEDS</option><option value="17">Matériels > PROTEGE TIBIAS et PIEDS velcro rouge</option><option value="69">Matériels > SHORT thaï</option><option value="68">Protéines > 3WHEY COMPLEX</option><option value="41">Protéines > 3WHEY COMPLEX</option><option value="1">Protéines > 3WHEY COMPLEX</option><option value="37">Protéines > 3WHEY COMPLEX</option><option value="31">Protéines > AMINO 3001</option><option value="43">Protéines > AMINO 3001</option><option value="67">Protéines > AMINO GAINER</option><option value="9">Protéines > AMINO GAINER</option><option value="21">Protéines > AMINO LIQUID 3001</option><option value="48">Protéines > AMINO RECUP</option><option value="55">Protéines > B-COMPLEX</option><option value="34">Protéines > BCAA 850</option><option value="70">Protéines > BCAA 850</option><option value="22">Protéines > BETAMAX</option><option value="18">Protéines > CARBO ENERGY</option><option value="13">Protéines > CARBO ENERGY</option><option value="23">Protéines > CHONDROMAX</option><option value="51">Protéines > CO-ENZYME Q10</option><option value="42">Protéines > CREATINE</option><option value="53">Protéines > CREATINE</option><option value="25">Protéines > CREATINE</option><option value="60">Protéines > CREATINE X-CELL</option><option value="73">Protéines > ENERGY GEL</option><option value="87">Protéines > ENERGY PRELOAD</option><option value="50">Protéines > GUARAMAX</option><option value="4">Protéines > HMB</option><option value="80">Protéines > HMB</option><option value="71">Protéines > HYDRA CUT</option><option value="16">Protéines > HYDROXYFREE</option><option value="62">Protéines > ISOMAX</option><option value="20">Protéines > ISOMAX</option><option value="84">Protéines > L-CARNITINE</option><option value="7">Protéines > L-CARNITINE LIQUID</option><option value="30">Protéines > L-GLUTAMINE</option><option value="57">Protéines > L.A.B.</option><option value="46">Protéines > LIFE QUALITY PACK</option><option value="86">Protéines > MASS GAINER</option><option value="12">Protéines > MASS GAINER</option><option value="85">Protéines > OXIFREE</option><option value="44">Protéines > PRO 85</option><option value="66">Protéines > PRO 85</option><option value="63">Protéines > PRO 85</option><option value="76">Protéines > PRO 95</option><option value="40">Protéines > PRO 95</option><option value="56">Protéines > RECUPERADE</option><option value="74">Protéines > THERMO STACK +</option><option value="19">Protéines > THERMO STACK 2</option><option value="14">Protéines > TRI-MINERAL</option><option value="3">Protéines > VITA-TONIC</option><option value="36">Protéines > VITA-TONIC</option><option value="26">Protéines > VITAMIN C</option><option value="77">Protéines > WHEY AMINO 10000</option><option value="79">Protéines > WHEY PRO</option><option value="54">Protéines > WHEY PRO</option><option value="2">Services > SAUNA 1 personne</option>        </select> </td>
  121.       <td colspan="2" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  122.           <tr align="left" valign="top" class="text">
  123.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">Quantit&eacute;
  124.               en stock :</td>
  125.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;" id="qt_stock">
  126.   </td>
  127.           </tr>
  128.           <tr align="left" valign="top" class="text">
  129.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">Prix
  130.               unitaire : </td>
  131.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;" id="pu">&nbsp;</td>
  132.           </tr>
  133.           <tr align="left" valign="top" class="text">
  134.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">Description
  135.               : </td>
  136.             <td width="50%" rowspan="3" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;" id="description">&nbsp;</td>
  137.           </tr>
  138.           <tr align="left" valign="top" class="text">
  139.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">&nbsp;</td>
  140.           </tr>
  141.           <tr align="left" valign="top" class="text">
  142.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">&nbsp;</td>
  143.           </tr>
  144.           <tr align="left" valign="top" class="text">
  145.             <td width="50%" class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">Ajouter
  146.               au panier :</td>
  147.             <td class="tab_arrow" style="font-weight: bold; padding: 4px; height: 24px;">
  148.               <select name="ajout_qt" class="frm1" id="ajout_qt" style="width: 100px;">               
  149.               </select>
  150.               <input name="ajout_article" type="button" id="ajout_article" value="Ajouter">
  151.               <a href="#" onClick='javascript:AjouterArticlePanier(1, 1);'>Ajouter</a></td>
  152.           </tr>
  153.         </table></td>
  154.     </tr>
  155.   </table>
  156. </form>
  157. <table id="tab_panier" align="center" class="text" style="width: 100%; font-size: 12px;  border: 1px dashed #000000;"  border="0" cellspacing="0" cellpadding="4">
  158.   <tr>
  159.     <td colspan="6" class="tab_title" style="border-bottom: 1px dashed #000000;font-weight: bold; text-align: center;">Panier</td>
  160.   </tr>
  161.   <tr align="left" valign="top">
  162.     <td class="tab_arrow" style="width: 10%; font-weight: bold; border-right: 1px dashed #000000; border-bottom: 1px dashed #000000;">N&deg;  </td>
  163.     <td class="tab_arrow" style="width: 35%; font-weight: bold; border-right: 1px dashed #000000; border-bottom: 1px dashed #000000;">Nom article </td>
  164.     <td class="tab_arrow" style="width: 15%; font-weight: bold; border-right: 1px dashed #000000; border-bottom: 1px dashed #000000;">Q.T.</td>
  165.     <td class="tab_arrow" style="width: 15%; font-weight: bold; border-right: 1px dashed #000000; border-bottom: 1px dashed #000000;">P.U.</td>
  166.     <td class="tab_arrow" style="width: 15%; font-weight: bold; border-right: 1px dashed #000000; border-bottom: 1px dashed #000000;">Total</td>
  167.     <td align="center" class="tab_arrow" style="width: 10%; font-weight: bold;  padding: 4px;border-bottom: 1px dashed #000000;">Effacer</td>
  168.   </tr>
  169. </table>
  170. <br>
  171. <br>
  172. </div></td>
  173.           </tr>
  174.       </table>
  175.     </td>
  176.   </tr>
  177.   <tr>
  178.     <td align="center" valign="bottom" style="height: 2px;">
  179. <div class="footer">
  180.  <div style="margin-top: 1px;"><div class="text" style="font-size: 10px; color: #EEEEEE;">
  181.   Page g&eacute;n&eacute;r&eacute;e en <b>0.75</b> secondes - <b>4</b> requ&ecirc;tes ont &eacute;t&eacute; execut&eacute;es.
  182.    </div></div>
  183.     </div>
  184. <div style="text-align: center;"><textarea name="debug" style="width: 942px; height: 315px; background-color: E8E6F2;"> Mode DEBUG activé
  185. -----------------
  186. 1. Requête :   SELECT * FROM admin_ip
  187.     Nb. Row :   2
  188. --------------------------------------------------------------------------------------------------------------------
  189. 2. Requête :   SELECT * FROM types_droits ORDER BY id_type_droit_parent DESC, ordre ASC;
  190.     Nb. Row :   54
  191. --------------------------------------------------------------------------------------------------------------------
  192. 3. Requête :   SELECT * FROM articles_en_stock ORDER BY nom_cat ASC, nom_article ASC
  193.     Nb. Row :   87
  194. --------------------------------------------------------------------------------------------------------------------
  195. 4. Requête :   SELECT * FROM articles_en_stock ORDER BY nom_cat ASC, nom_article ASC
  196.     Nb. Row :   87
  197. --------------------------------------------------------------------------------------------------------------------
  198. </textarea></div>
  199. </td>
  200.   </tr>
  201. </table>
  202. </body>
  203. </html>


 
 
 
 
Je sais, ca fait mal aux yeux et je m'en excuse.
 
Donc tout le probleme vient du fait que une fonction marche un coup et dans un autre cas elle ne marche pas alors qu'il n'y a aucune raison !!
 
En résumé :
 

Code :
  1. function MajInfosArticle(IdArticle) {
  2. var i;
  3. for(i=0; i<tab_articles.length; i++) {
  4.  if(tab_articles[i]["id_article"]==IdArticle) {
  5.   // ICI CA MARCHE NICKEL !!!!! POURQUOI?    
  6.   ChangerTexteBalise("qt_stock", tab_articles[i]["qt_achete"]-tab_articles[i]["qt_vendu"]);
  7.   ChangerTexteBalise("pu", tab_articles[i]["prix_vente"]+" &euro;" );
  8.   ChangerTexteBalise("description", tab_articles[i]["description"]);
  9.   FillAjoutArticleCmb(tab_articles[i]["qt_achete"]-tab_articles[i]["qt_vendu"]);
  10.   return true;
  11.  }
  12. }
  13. }

Fonctionne NICKEL !
 
Mais ca :

Code :
  1. // Ajoute une ligne au tableau (id: tab_panier)
  2. function AjouterArticlePanier(IdArticle, qt) {
  3. var html_line;
  4. var i;
  5. // On récupere le header du tableau si ce n'est pas deja fait
  6. if(tab_panier_header_html.length<1) {
  7.  tab_panier_header_html=document.getElementById('tab_panier').innerHTML;
  8.  tab_panier_header_html=tab_panier_header_html.replace("<tbody>", "" );
  9.  tab_panier_header_html=tab_panier_header_html.replace("</tbody>", "" );
  10.  tab_panier_header_html=tab_panier_header_html.replace("<TBODY>", "" );
  11.  tab_panier_header_html=tab_panier_header_html.replace("</TBODY>", "" );
  12. }
  13. // On recherche les infos dans le tableau
  14. for(i=0; i<tab_articles.length; i++) {
  15.  if(tab_articles[i]["id_article"]==IdArticle) { // Si Article trouvé, on ajoute
  16.   // code html de la ligne a ajouter
  17.   //html_line="<tr align=\"left\" valign=\"top\"><td class=\"tab_arrow\">"+tab_articles[i]["id_article"]+"</td><td class=\"tab_arrow\">"+tab_articles[i]["nom_article"]+"</td><td class=\"tab_arrow\">"+qt+"</td><td class=\"tab_arrow\">"+tab_articles[i]["prix_vente"]+" &euro;</td><td class=\"tab_arrow\" style=\"font-weight: bold;\">"+(qt*tab_articles[i]["prix_vente"])+" &euro;</td><td align=\"center\" class=\"tab_arrow\"><img src=\"../../design/btn-supprimer.gif\" width=\"20\" height=\"20\"></td></tr>";
  18.   html_line="test";
  19.   //alert(tab_panier_header_html+html_line);
  20.   // On insere la ligne dans le tableau html
  21.   document.getElementById('tab_panier').innerHTML=html_line;  // ICI CA MERDE SANS RAISON !!!!!!!!!!
  22.   // On ajoute l'id de l'article au panier
  23.   //panier[panier.length]=IdArticle;
  24.  }
  25. }
  26. }


 
Je peux danser sur ma tete et faire tout les test que je veux cette ligne

Code :
  1. ChangerTexteBalise("tab_panier", html_line);  // ICI CA MERDE SANS RAISON !!!!!!!!!!


 
Provoque une erreur JS! Et quelle erreur.... super explicite : "Erreur d'execution inconnue"
 
 
Supair
 
Voila si tu peux m'aider a comprendre ce probleme abérant je te serais tres reconnaissant :)
 
A+ merci


Message édité par Gat$ le 25-08-2005 à 14:02:50

---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184211
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 14:03:39  profilanswer
 

A noter que :  
 
ChangerTexteBalise("tab_panier", html_line);
 
j'ai essayer en insérant directement ceci :  
 
document.getElementById('tab_panier').innerHTML=html_line;
 
 
Et ca a rien changer, il ne veut pas de getelementbyid a ce stade, pour une raison completement incompréhenssible !


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184219
gatsusat
Posté le 25-08-2005 à 14:08:34  profilanswer
 

je te fais ca dans l'a^prem si j'ai le temps, mais ya du bancalisme a fond dans ton code, je t'expliquerai pkoi

mood
Publicité
Posté le 25-08-2005 à 14:08:34  profilanswer
 

n°1184224
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 14:09:55  profilanswer
 

A noter aussi que sous mozilla ca marche
 
et que hier ca marchait sur les 2 explorer et mozilla sans changemetn majeur.
 
D'ou mon incomprehenssion totale et mon enervement :/


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184227
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 14:10:43  profilanswer
 

Gatsusat ok merci, mais pr le moment mon code c pas le prob, je veux  juste piger prkoi ce con de explorer accepte dans un cas et pas dans un autre, c'est completement fou.
 
Merci d'avance entk


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184234
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 14:14:28  profilanswer
 

J'ai fait un test qui m'a permis de +- localiser le probleme, sans trouver de soluce.
 
Ceci placé a la fin du code html:  
 
<script language="JavaScript">
 document.getElementById('pu').innerHTML="test";  
</script>
 
marche
 
mais ceci placé au meme endroit :  
 
<script language="JavaScript">
 document.getElementById('tab_panier').innerHTML="test";  
</script>
 
Ne marche pas
 
Donc le probleme vient de l'objet tab_panier, pour une raison completement abérante explorer ne le reconnait pas comme un objet!
 
Voila...
 
 
 
EDIT :  
------
 
 
Après d'autres test apparemment c'est le fait que ca soit un tableau qui fait merder.
 
Conclusion on lne peut pas utiliser de id= dans les tableau ???? C'est nouveau?


Message édité par Gat$ le 25-08-2005 à 14:18:31

---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184279
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 14:53:05  profilanswer
 

Bon j'ai essayé une autre méthode qui apparemment est DOM.
 
function AjouterArticlePanier(IdArticle, qt) {
 var html_line;
 var i;
 
 // On recherche les infos dans le tableau
 for(i=0; i<tab_articles.length; i++) {
  if(tab_articles[i]["id_article"]==IdArticle) { // Si Article trouvé, on ajoute
   
   var Cell1 = document.createElement('td');
   var Cell2 = document.createElement('td');
   
   Cell1.appendChild(document.createTextNode('test1'));
   Cell2.appendChild(document.createTextNode('test2'));
   
   var Row = document.createElement('tr');
   Row.appendChild(Cell1);
   Row.appendChild(Cell2);
   
   document.getElementById("tab_panier" ).appendChild(Row);    
  }
 }
}
 
 
 
et pourtant ca marche que sous mozilla, j'en ai marre :(


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184280
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 14:55:57  profilanswer
 

Ah ben si ca marche si on met le id dans le tbody
 
Bon ben finalement j'y suis arrivé tout seul lol
 
Merci quand meme pour ton aide gatsusat!
 
Mais je reviens pas sur mon jugement JS c'est vraiment gavant comme language ! :D


Message édité par Gat$ le 25-08-2005 à 14:56:53

---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184337
zapan666
Tout est relatif
Posté le 25-08-2005 à 15:56:44  profilanswer
 

Gat$ a écrit :


Code :
  1. <td valign="top" style="text-align: center; width: 268px; height: 400px;">
  2.    <a href="admin.php" class="submenu">&nbsp;&nbsp;&nbsp;<span style="color: #FFBE00; font-weight: vold;">Administration...</span></a><a href="admin.php?s2=gestion_membres" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Membres</a><a href="admin.php?s2=gestion_employes" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Employ&eacute;s</a><a href="admin.php?s2=gestion_cours" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Disciplines</a><a href="admin.php?s2=gestion_ventes" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-close.gif" border="0" alt=""/> Ventes</a><a href="admin.php?s2=gestion_stocks" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-open.gif" border="0" alt=""/> Stocks</a><a href="admin.php?s2=config" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-nothing.gif" border="0" alt=""/> Configuration</a><a href="admin.php?s2=loggout" class="submenu">&nbsp;&nbsp;&nbsp;<img src="design/submenu-nothing.gif" border="0" alt=""/> Se déconnecter</a><br></div>
  3. </td>



 :ouch: le pavé !
t'arrivce a t'y retrouver ??
les &nbsp;, tu dois pouvoir les eviter en stylant correctement tes icones (propriété margin en CSS)

Gat$ a écrit :


Mais je reviens pas sur mon jugement JS c'est vraiment gavant comme language ! :D


Bah en fait quand tu pige plus ou moins le truc, le JS, c'est vraiment puissant. Je fais des p'tits patch JS pour des pages en ce moment, et bien que ce que je fais c'est tout petit, je trouve ça assez puissant, mais il faut bien gerer son truc.


---------------
my flick r - Just Tab it !
n°1184347
Gat$
http://www.wowteamfinder.com
Posté le 25-08-2005 à 16:04:34  profilanswer
 

zapan666 a écrit :

:ouch: le pavé !
t'arrivce a t'y retrouver ??
les &nbsp;, tu dois pouvoir les eviter en stylant correctement tes icones (propriété margin en CSS)
 
Bah en fait quand tu pige plus ou moins le truc, le JS, c'est vraiment puissant. Je fais des p'tits patch JS pour des pages en ce moment, et bien que ce que je fais c'est tout petit, je trouve ça assez puissant, mais il faut bien gerer son truc.


 
J'imagine mais combien de fois j'ai ete bloqué pendant des heures pour une conneries du style en JS!
Sinon le pavé en question est généré par une boucle, et donc oui je m'y retrouve car dans le code y a pas grand chose d'affiché :o). Mais ok le &nbsp; c'est plus par flemme qu'autre chose, j'avoue, mais bon c vite changé aussi :)
 
Gat$


---------------
Recherche de partenaires pvp dans World of Warcraft :: http://www.wowteamfinder.com
n°1184547
gatsusat
Posté le 25-08-2005 à 18:56:42  profilanswer
 

zapan666 a écrit :

:ouch: le pavé !
t'arrivce a t'y retrouver ??
les &nbsp;, tu dois pouvoir les eviter en stylant correctement tes icones (propriété margin en CSS)
 
Bah en fait quand tu pige plus ou moins le truc, le JS, c'est vraiment puissant. Je fais des p'tits patch JS pour des pages en ce moment, et bien que ce que je fais c'est tout petit, je trouve ça assez puissant, mais il faut bien gerer son truc.


 
Avec GreaseMonkey pour FF ou Trikie pour IE tu peux utiliser des script JS pour modifier des pages web
 
Je m'en suis servi pour les utiliser sur un forum de Manga qui file des liens vers des fansubs. et au lieu de cliquer sur chaque lien comme un con, j'ai un script JS qui recupère tous les liens, et les transforme en text brut, ensuite j'ai plus qu'à prendre l'ensemble des liens et faire un C/C dans la mule


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

  Recuperer tout le contenu d'une balise (A L'AIDE :((( )

 

Sujets relatifs
comment récuperer des infos d'un fichier .txtDe l'aide pour me dire si c'est correct ???
Récupérer le numéro DD d'une machineremplacer une URL dans une string par une balise html [Résolu]
De l'aide sur la fonction "Include", s'il vous plait!récupérer l'année
récupérer nom de la classe mèreBesoin d'aide pour réaliser un caddie..
Active directory recuperer le champ pictureComment récuperer $_GET['machin'] en $machin ? [résolu]
Plus de sujets relatifs à : Recuperer tout le contenu d'une balise (A L'AIDE :((( )


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