<html>
<head>
<title>TEST SPOSTAMENTO CURSORI SU TABELLA </title>
<script type="text/javascript" language="javascript" >
var R = 1, C = 1;
var nrows = 6, ncells = 24;
function SpostaUpDown(R, C, e) {
var code = e.keyCode ? e.keyCode : e.charCode
// alert("left");
if (code == 37) {SetFocus(R, C - 1);}
// alert("right");
if (code == 39) {SetFocus(R, C + 1);}
if (code == 38) { SetFocus(R - 1, C); }
if (code == 40) { SetFocus(R + 1, C); }
if (code == 13) {
// alert(code);
Invio(R, C, e);
}
// invio
}
function SetFocus(R, C) {
// alert("call to setfocus "+R+" "+C);
if (R==0) {
R=1;
C=1;
}
if (R>nrows) {R=6};
//if (C==0 || C==7) {C=1};
if (C>ncells) {
C=1;
R=R+1;
if (R>6) {R=6}
}
// SalvaCursore( R, C);
document.getElementById("R"+R+"C"+C).focus();
// document.getElementById("R"+R+"C"+C).select();
}
function Invio(R, C, e) {
var code = e.keyCode ? e.keyCode : e.charCode;
if (code == 13) {
ElaboraDatiForm(R, C);
return true; ;
}
else {
return false;
}
}
function ElaboraDatiForm(R, C) {
alert("elaboro cella a RIGA=" + R + ", COL.=" + C);
bckMainPage();
}
function NumbersOnly(myfield, e, dec) {
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
// control keys
if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
return true;
// numbers
else
if ((("0123456789,").indexOf(keychar) > -1))
return true;
else
return false;
}
function LettersOnly(myfield, e, dec) {
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
// alert("code=" + keychar+"-"+key);
// control keys
if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
return true;
// numbers
else if ((("abcdefghilmnopqrstuvzwxyjkABCDEFGHILMNOPQRSTUV ZWXYK .,àèìòù&0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}
function CellaPiena(R,C) {
if (document.getElmentById("R"+R+"C"+C).value!="") {
// skip to next cell
document.getElmentById("R"+R+"C"+C).setAttribute(" backgroundColor","#FFFFFF");
SetFocus(R,C+1);
}
document.getElmentById("R"+R+"C"+C).setAttribute(" backgroundColor","#8AF4F4");
}
</script>
<style type="text/css">
<!--
input.objAttivo:hover {
background-color: #3399FF;
color:#000000;
}
input.objAttivo:active {
background-color:#FFFFFF;
}
input.objAttivo1 {
background-color: #666666;
color:#FFFFFF;
text-align:center;
}
-->
</style></head>
</head>
<body>
<table>
<script language="javascript" type="text/javascript">
for (var R = 1; R < nrows + 1; R++) {
document.write("<tr>");
for (var C=1; C < ncells; C++) {
document.write("<td>");
document.write("<input type=text size=1 value='' onkeypress='return LettersOnly(this, event)' onKeyDown='SpostaUpDown("+R+","+C+", event)' ");
document.write(" id='R" + R + "C" + C + "' name='R" + R + "C" + C + "'");
document.write(" onFocus=this.style.backgroundColor='#8AF4F4' onBlur=this.style.backgroundColor='#ffffff' />");
document.write("</td>");
}
document.write("</tr>");
}
</script>
</table>
</body>
</html>