Visualizzazione dei risultati da 1 a 10 su 28

Visualizzazione discussione

  1. #9
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    592
    Quote Originariamente inviata da vitren54 Visualizza il messaggio
    OK per l'id="R+riga+C+colonna"

    qualche dubbio sul campo di edit...
    il campo di edit è lungo 1 e pensavo ad un comportamento simile al TAB che salta da una cella all'altra indipendentemente dal fatto che sia piena o vuota.

    Si il load delle celle lo faccio con PHP che inserisce un campo di input se la cella è vuota o visualizza il valore e quindi la cella deve essere scavalcata nello spostamento del cursore.
    Ciao
    come ti avevo promesso ho dato una occhiata al lato programmazione del problema e ti posto
    il piccolo file tanto per cominciare ...poi ci devi lavorare tu sopra...
    <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>
    fammi sapere come procederai che sono curioso...
    ciao
    Ultima modifica di vic53; 22-12-2015 a 19:07
    Vic53

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.