<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="Scripts/jquery-1.9.0.min.js"
type="text/javascript"></script>
    <script type="text/javascript">
       
$(document).ready(function () {
           
$(':text').keypress(function (e) {
               
var keyCode = e.keyCode || e.which;
               
var SideMax = 3;
               
var SideMin = 1;
               
var Upmax = 1;
               
var Upmin = 3;
               
var Row = +$(this).attr("attr-Row");
               
var Col = +$(this).attr("attr-Colum");
               
arrow = { left: 37, up: 38, right: 39, down: 40 };
               
if (e.ctrlKey) {
                   
switch (keyCode) {
                        case 37:
                            if
(Col <= SideMax) {
                                SetFocuz(Row + '' + Col - 1);
                            }
                            break;
                        case 39:
                            if (Col >= SideMin) {
                                Col = Col + 1;
                                SetFocuz(Row + '' + Col);
                            }
                            break;
                        case 38:
                            if (Col < Upmax) {
                                SetFocuz(Row -
1 + '' + Col);
                            }
                            break;
                        case 40:
                            if (Col < Upmin) {
                                SetFocuz(Row +
1 + '' + Col);
                            }
                            break;
                   
}
               
}
           
});
        });
        function SetFocuz(attrValue) {
           
alert(attrValue);
           
$(':Text').each(function () {
               
if ($(this).attr('attrFocuz') == attrValue) {
                   
$(this).focus();
               
}
           
});
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
               
<td>
                   
<asp:TextBox ID="txt01" attr-Row="1"
attr-Colum="1"
attrFocuz="11"
runat="server"></asp:TextBox>
               
</td>
               
<td>
                   
<asp:TextBox ID="TextBox2"
attr-Row="1"
attr-Colum="2"
attrFocuz="12"
runat="server"></asp:TextBox>
               
</td>
               
<td>
                   
<asp:TextBox ID="TextBox1"
attr-Row="1"
attr-Colum="3"
attrFocuz="13"
runat="server"></asp:TextBox>
               
</td>
            </tr>
            <tr>
               
<td>
                   
<asp:TextBox ID="TextBox3"
attr-Row="2"
attr-Colum="1"
attrFocuz="21"
runat="server"></asp:TextBox>
               
</td>
               
<td>
                   
<asp:TextBox ID="TextBox4"
attr-Row="2"
attr-Colum="2"
attrFocuz="22"
runat="server"></asp:TextBox>
               
</td>
               
<td>
                   
<asp:TextBox ID="TextBox5"
attr-Row="2"
attr-Colum="3"
attrFocuz="23"
runat="server"></asp:TextBox>
               
</td>
            </tr>
            <tr>
               
<td>
                   
<asp:TextBox ID="TextBox6"
attr-Row="3"
attr-Colum="1"
attrFocuz="31"
runat="server"></asp:TextBox>
               
</td>
               
<td>
                   
<asp:TextBox ID="TextBox7"
attr-Row="3"
attr-Colum="2"
attrFocuz="32"
runat="server"></asp:TextBox>
               
</td>
               
<td>
                   
<asp:TextBox ID="TextBox8"
attr-Row="3"
attr-Colum="3"
attrFocuz="33"
runat="server"></asp:TextBox>
               
</td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
 
No comments:
Post a Comment