1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>...</title>
<style type="text/css">
#liste {
cursor:pointer;
height:100px;
list-style-type:none;
margin:50px;
padding:0px;
}
#liste li {
float:left;
width:50px;
background-color:#ffffff;
border:1px solid #000000;
}
#op {
margin-left:50px;
width:320px;
padding-left:20px;
border:2px ridge #ff0000;
}
</style>
</head>
<body>
<ul id="liste">
<li>8h</li>
<li>8h30</li>
<li>9h</li>
<li>9h30</li>
<li>10h</li>
<li>10h30</li>
<li>11h</li>
<li>11h30</li>
<li>12h</li>
<li>12h30</li>
</ul>
<p id="op">
<strong>Choisissez le temps de réservation souhaitée puis cliquez sur un horaire de début de séance.</strong><br />
<input type="radio" checked="checked" name="r" value="2" />1h<br />
<input type="radio" name="r" value="3" />1h30<br />
<input type="radio" name="r" value="4" />2h
</p>
<script type="text/javascript">
var ra=document.getElementsByName("r");
var ul=document.getElementById("liste").getElementsByTagName("li");
var n=2;
var t=[];
var q=[-2,-1,ul.length,ul.length+1];
for(i=0;i!=ra.length;i++){
ra[i].onclick=function(){
n=parseInt(this.value)
}
}
for(i in q){
t[q[i]]=true
}
for(i=0;i!=ul.length;i++){
ul[i].ind=i;
ul[i].onclick=function(){
if(t[this.ind-2] && !t[this.ind-1] || !t[this.ind+n] && t[this.ind+n+1]){
alert("Créneau indisponible.\n\nChoisissez éventuellement une durée de jeu différente.");
return
}
for(j=0;j<n;j++){
if(t[this.ind+j]){
alert("Créneau indisponible.\n\nChoisissez éventuellement une durée de jeu différente.");
return
}
}
for(j=0;j<n;j++){
t[this.ind+j]=true;
ul[this.ind+j].style.backgroundColor="#00ff00";
}
alert("Votre réservation est prise en compte de " + this.firstChild.data + " à " + ul[this.ind+n-1].firstChild.data)
for(j=0;j<n;j++){
ul[this.ind+j].style.backgroundColor="#ff0000";
}
}
}
</script>
</body>
</html> |