[javascript]changer un tableaux dynamiquement
triblekano
Messages postés
169
Date d'inscription
Statut
Membre
Dernière intervention
-
triblekano Messages postés 169 Date d'inscription Statut Membre Dernière intervention -
triblekano Messages postés 169 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'essaie de programmais un calendrier en java-scripte tous marche bien mais le problème cest quand on change le mois je un nouveaux tableaux du nouveaux mois et l ancien reste afficher se que je veux mois c'est le nouveaux écrase l ancien
et merci je vous laisse le code
j'essaie de programmais un calendrier en java-scripte tous marche bien mais le problème cest quand on change le mois je un nouveaux tableaux du nouveaux mois et l ancien reste afficher se que je veux mois c'est le nouveaux écrase l ancien
et merci je vous laisse le code
<script> var M=1; var A=1; var Table; Table.id='cland'; var tablebody; var body ; function mois_s() { M=M+1; calandrier(M,A) } function mois_p() { M=M-1; calandrier(M,A) } function calandrier(m,a) { var mois=m; var annes=a; var jours_debut=new Date(annes,mois,1,12).getDay(); var nombre_jours=new Date(annes,mois+1,0,12).getDate(); var jours_actuelle=1; // création des cellules jour th=document.createElement("th"); th.appendChild(document.createTextNode("Dim")); tablebody.appendChild(th); th=document.createElement("th"); th.appendChild(document.createTextNode("Lun")); tablebody.appendChild(th); th=document.createElement("th"); th.appendChild(document.createTextNode("Mar")); tablebody.appendChild(th); th=document.createElement("th"); th.appendChild(document.createTextNode("Mer")); tablebody.appendChild(th); th=document.createElement("th"); th.appendChild(document.createTextNode("Jeu")); tablebody.appendChild(th); th=document.createElement("th"); th.appendChild(document.createTextNode("Ven")); tablebody.appendChild(th); th=document.createElement("th"); th.appendChild(document.createTextNode("Sam")); tablebody.appendChild(th); // création des cellules de la premier ligne var row = document.createElement("tr"); for(var j = jours_debut; j >0; j--) { // crée une ligne vide cell = document.createElement("td"); texte = document.createTextNode(" "); cell.appendChild(texte); row.appendChild(cell); } for(var j = jours_debut; j <7; j++) { // commancé a crée les jours cell = document.createElement("td"); texte = document.createTextNode(jours_actuelle); jours_actuelle++; cell.appendChild(texte); row.appendChild(cell); } // ajoute la ligne à la fin du corps du tableau tablebody.appendChild(row); while (jours_actuelle<=nombre_jours) { row = document.createElement("tr"); for(var j = 0; j <7; j++) { if(jours_actuelle<=nombre_jours) { // crée une ligne de tableau cell = document.createElement("td"); texte = document.createTextNode(jours_actuelle); jours_actuelle++; cell.appendChild(texte); row.appendChild(cell); } else { cell = document.createElement("td"); texte = document.createTextNode(""); cell.appendChild(texte); row.appendChild(cell); } } tablebody.appendChild(row); } // place <tbody> dans l'élément <table> Table.appendChild(tablebody); // ajoute <table> à l'élément <body> body.appendChild(Table); } function start() { var x = new Date(); Table= document.createElement("table"); tablebody = document.createElement("tbody"); body= document.getElementById("tab"); M=x.getMonth();A=x.getFullYear(); calandrier(M,A) ; }
A voir également:
- [javascript]changer un tableaux dynamiquement
- Changer dns - Guide
- Comment faire un tableau croisé dynamique - Guide
- Changer carte graphique - Guide
- Changer wifi chromecast - Guide
- Changer extension fichier - Guide