File "keynum05.html"

Full Path: /home/analogde/www/RaspBerry/HTML/keynum05.html
File size: 2.34 KB
MIME-type: text/html
Charset: utf-8

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style type='text/css'>
td {cursor:hand;}
.up {	border: outset 2 px gray;
 height:20px;
 width:20px;
 font-family:verdana;
 text-align:center;
}
.down {border: inset 2 px gray;
 height:20px;
 width:20px;
 font-family:verdana;
 text-align:center;
}
</style>
<script type='text/javascript'>
var activeinput
function populateTd()
{
var tdcollection = document.getElementsByTagName('table')[0].getElementsByTagName('td');
for (i = 0 ; i < tdcollection.length ; i++)
{
 tdcollection[i].indice = i;
 tdcollection[i].className = 'up';
 tdcollection[i].onmousedown = function()
 {
 	this.className = 'down';
 }
 tdcollection[i].onmouseup = function()
 {
 	this.className = 'up';
 }
 tdcollection[i].onclick = function()
 {
 	if (!!activeinput)
 	{
   // pour entrer le numéro sur lequel on vient de taper
   if(this.indice < 11)
   {
   	activeinput.value += this.innerHTML;
   }
   // pour effacer le dernier caractere
   if(this.indice == 11)
   {
   	activeinput.value = activeinput.value.substr(0,activeinput.value.length-1);
   }
   // pour tout effacer
   if(this.indice == 12)
   {
   	activeinput.value = "";
   }
 	}
 }
}
}
function highlightActive(obj)
{
var inputcollection = document.getElementsByTagName('input');
for(i = 0 ; i < inputcollection.length ; i++)
{
    inputcollection[i].style.backgroundColor = (inputcollection[i]==obj) ? "lime" : "white";
}
}
</script>
<title>Pavé numérique</title>
</head>
<body onload='populateTd()'>
<table>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td colspan=2>0</td>
<td>.</td>
</tr>
<tr>
<td colspan=2>CE</td>
<td>CA</td>
</tr>
</table>
<br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
<input type='text' onFocus="highlightActive(this);activeinput=this" /><br/>
</body>
</html>