phpJSvForm
v11.11.12
Des classes PHP, des JavaScripts pour créer facilement un formulaire.
|
00001 /******************************************************************************* 00002 This file is part of 'phpJSvForm'. 00003 Copyright (C) 2010 Pierre POISSON (synanceia) 00004 00005 'phpJSvForm' is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 'phpJSvForm' is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with 'phpJSvForm'. If not, see <http://www.gnu.org/licenses/>. 00017 *******************************************************************************/ 00018 00036 /******************************************************************************* 00037 Historique : ------------------------------------------------------------------- 00038 27/07/2010 PP Création du fichier 00039 04/08/2010 PP Ajout test sur 'INPUT' : ne doit pas être de type 'hidden' 00040 13/08/2010 PP Première version finalisée 00041 xx/11/2011 PP Documentation au format doxygen 00042 *******************************************************************************/ 00043 var calendrier = new CalendarPopup("Calendrier") ; 00044 00053 function ajouteLienSelecteur() 00054 { 00055 var champsSaisie,selectLien,selectTexte; 00056 00057 // boucle sur tous les champs de saisie 00058 champsSaisie=document.getElementsByTagName('input'); 00059 for(i=0;i<champsSaisie.length;i++) 00060 { 00061 00062 // si l'attribut 'id' commence par 'date' 00063 if(/^date/.test(champsSaisie[i].id) && champsSaisie[i].type=="text") 00064 { 00065 00066 // créer un nouveau lien et un nouveau texte 00067 selectLien=document.createElement('a'); 00068 selectTexte=document.createTextNode('Calendrier'); 00069 00070 // ajoute le texte en tant qu'enfant du lien 00071 selectLien.appendChild(selectTexte); 00072 00073 // change l'adresse de destination href à # et appelle le sélecteur 00074 // lors d'un clic ou d'un focus sur le lien 00075 // 'this.previousSibling' désigne le champ de saisie (il précèdera ce lien) 00076 // 'this.id' vaudra 'anchor_cal'+i 00077 selectLien.setAttribute('href','#'); 00078 selectLien.onclick=function(){calendrier.select(this.previousSibling,this.id,'dd/MM/yyyy');return false;} ; 00079 //selectLien.onkeypress=function(){}; 00080 00081 selectLien.setAttribute('title','Calendrier '+i); 00082 selectLien.setAttribute('name','anchor_cal'+i); 00083 selectLien.setAttribute('id','anchor_cal'+i); 00084 selectLien.setAttribute('class','petit'); 00085 // ajoute le nouveau lien directement après le champ de saisie 00086 champsSaisie[i].parentNode.insertBefore(selectLien,champsSaisie[i].nextSibling); 00087 00088 if(!document.getElementById('Calendrier')) // Si elle n'existe pas ... 00089 { 00090 //crée une nouvelle DIV pour accueillir le calendrier 00091 selectDiv=document.createElement('div'); 00092 selectDiv.setAttribute('id','Calendrier'); 00093 00094 // ajoute la nouvelle DIV après le parent du champ de saisie 00095 champsSaisie[i].parentNode.parentNode.insertBefore(selectDiv,champsSaisie[i].parentNode.nextSibling) ; 00096 } 00097 } 00098 } 00099 } 00100 00101 /* ***************************** Window.onLoad ***************************** */ 00105 addLoadEvent(ajouteLienSelecteur); 00106