summaryrefslogtreecommitdiff
path: root/maquette/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'maquette/script.js')
-rw-r--r--maquette/script.js88
1 files changed, 65 insertions, 23 deletions
diff --git a/maquette/script.js b/maquette/script.js
index 39c27d1..2dd33e9 100644
--- a/maquette/script.js
+++ b/maquette/script.js
@@ -31,8 +31,12 @@ function removePers(form)
}
}
-function loadpop(url,id) {
- document.getElementById(id).innerHTML = "<em>Chargement en cours ...<br/><a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a><em>";
+function loadid(url,id,isPop) {
+ if (isPop)
+ document.getElementById(id).innerHTML = "<em>Chargement en cours ...<br/><a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a></em>";
+ else
+ document.getElementById(id).innerHTML = "<em>Chargement en cours ...</em>";
+
var http_request = false;
@@ -62,7 +66,10 @@ function loadpop(url,id) {
if (http_request.status == 200) {
document.getElementById(id).innerHTML = http_request.responseText;
} else {
- document.getElementById(id).innerHTML = "<em>Un probl&egrave;me est survenu ...<br/><a href=\"#\" onclick=\"loadpop('"+url+"','"+id+"')\" >R&eacute;essayer</a> - <a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a><em>";
+ if (isPop)
+ document.getElementById(id).innerHTML = "<em>Un probl&egrave;me est survenu ...<br/><a href=\"#\" onclick=\"loadid('"+url+"','"+id+"',true)\" >R&eacute;essayer</a> - <a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a></em>";
+ else
+ document.getElementById(id).innerHTML = "<em>Un probl&egrave;me est survenu ...<br/><a href=\"#\" onclick=\"loadid('"+url+"','"+id+"',false)\" >R&eacute;essayer</a></em>";
}
}
};
@@ -91,22 +98,25 @@ function addcreneau(form)
{
if(form.day.options.selectedIndex>=0 && form.month.options.selectedIndex>=0 && form.year.options.selectedIndex>=0 && form.hourStart.options.selectedIndex>=0 && form.minuteStart.options.selectedIndex>=0 && form.hourEnd.options.selectedIndex>=0 && form.minuteEnd.options.selectedIndex>=0)
{
- //Création de la valeur
- var oValue = form.hourStart.options[form.hourStart.options.selectedIndex].value + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value;
- oValue = oValue + form.day.options[form.day.options.selectedIndex].value + form.month.options[form.month.options.selectedIndex].value + form.year.options[form.year.options.selectedIndex].value;
-
- //Test si la valeur est déja dans la liste
- var exist = false;
- var i = 0;
- while (i<form.creneaux.options.length && !exist) { if (form.creneaux.options[i].value == oValue) exist = true; i=i+1;}
-
- //Création du texte et de l'option et insertion de l'option si la valeur n'a pas été trouvée
- if (!exist)
+ if (verifDate(form.day.options[form.day.options.selectedIndex].value,form.month.options[form.month.options.selectedIndex].value,form.year.options[form.year.options.selectedIndex].value))
{
- var oText = form.hourStart.options[form.hourStart.options.selectedIndex].value + ":" + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + " -> " + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + ":" + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value;
- oText = oText + " " + form.day.options[form.day.options.selectedIndex].value + "/" + form.month.options[form.month.options.selectedIndex].value + "/" + form.year.options[form.year.options.selectedIndex].value;
- var o = new Option(oText,oValue);
- form.creneaux.options[form.creneaux.options.length]=o;
+ //Création de la valeur
+ var oValue = form.hourStart.options[form.hourStart.options.selectedIndex].value + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + "." + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value;
+ oValue = oValue + "." + form.day.options[form.day.options.selectedIndex].value + "." + form.month.options[form.month.options.selectedIndex].value + "." + form.year.options[form.year.options.selectedIndex].value;
+
+ //Test si la valeur est déja dans la liste
+ var exist = false;
+ var i = 0;
+ while (i<form.creneaux.options.length && !exist) { if (form.creneaux.options[i].value == oValue) exist = true; i=i+1;}
+
+ //Création du texte et de l'option et insertion de l'option si la valeur n'a pas été trouvée
+ if (!exist)
+ {
+ var oText = form.hourStart.options[form.hourStart.options.selectedIndex].value + ":" + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + " -> " + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + ":" + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value;
+ oText = oText + " " + form.day.options[form.day.options.selectedIndex].value + "/" + form.month.options[form.month.options.selectedIndex].value + "/" + form.year.options[form.year.options.selectedIndex].value;
+ var o = new Option(oText,oValue);
+ form.creneaux.options[form.creneaux.options.length]=o;
+ }
}
}
}
@@ -128,19 +138,51 @@ function removecreneau(form)
function dataListe(idSelect,idInput)
{
var liste = document.getElementById(idSelect);
- var champs = document.getElementById(idInput);
- var data = "";
- if (liste && champs)
+ if (liste)
{
for (var i=0;i<liste.options.length;i++)
{
- data = data + idInput + "[" + i + "]" + liste.options[i].value + "&";
+ var newInput = document.createElement("input");
+/* newInput.setAttribute("type", "hidden");
+ newInput.setAttribute("name", (idInput+"["+i+"]"));
+ newInput.setAttribute("value", liste.options[i].value);*/
+ newInput.type = "hidden";
+ newInput.name = idInput+"["+i+"]";
+ newInput.value = liste.options[i].value;
+ liste.form.appendChild(newInput);
}
- champs.value = data;
return (true);
}
else
{
return (false);
}
+
+}
+function verifDate(day,month,year)
+{
+ var a= year;
+ var m= month;
+ var d= day;
+ var ok=true;
+
+ var date2=new Date(a,m-1,d);
+ d2=date2.getDate();
+ m2=date2.getMonth()+1;
+ a2=date2.getFullYear();
+ if (a2<=100) {a2=1900+a2} //Pour depasser 2000
+ if ( (d!=d2)||(m!=m2)||(a!=a2) )
+ {
+ alert("Cette date n'existe pas !");
+ ok=false;
+ }
+ return (ok);
+}
+function loadlist(url,id,idListe)
+{
+
+ if (document.getElementById(id))
+ {
+ loadid((url+document.getElementById(id).options[document.getElementById(id).options.selectedIndex].value),idListe,false);
+ }
} \ No newline at end of file