做项目的时候碰到一个很头疼的问题,就是,用gridview生成很多的行的时候,gridview里有很多的文本框,其中有个文本框记录的是数量,ID是TextBox5,不变的,现在有一个问题就是,当gridview中有很多的行的时候,当光标在这个文本框里的时候,按 “下” 方向键的时候,要把光标定位到下一行的那个文本框中去....请高手教一教啊!
解决方案 »
- 如何实现动态生成.aspx和.cs文件的增删改查功能?
- 用ajax实现了输入框的suggest功能,但是还有个疑问
- 服务模型是什么?
- 全局错误页面处理问题,在线等
- 怎样在asp.net的隐藏代码里给服务器的表格添加行和列????
- 50分求推荐 NET 2.0的书
- asp加载swf问题(在线等)
- vss8的web配置问题,已经有人问了,一直没答案。
- 有人说JSP可以跨平台比asp.net好,是这样的吗?
- 求助!程序在本地没有错,上传到网上出错了!
- 刚用asp.net做了个ftp上传功能,在vs2008调试的时候可以把本地本件上传到ftp服务器,但是一发布到iis就不
- 急,急,基于silverlight的导入谁会呀(不要用C#,因为.xaml里没有所要的命名空间)
通过tab键来切换焦点
查询下行textbox
{
for(int i=0; i < 10; i++)
{
//这样每个textbox都有一个规律的索引值
this.tb.Attributes.Add("Index",i.ToString());
}
}
//前台,为他们注册事件
<input Index="1" onkeyup="move(this)"/>
<input Index="2" onkeyup="move(this)"//>
<input Index="3" onkeyup="move(this)"//>
var move = function(obj){
var direction;
if(window.event.keyCode == 38)
direction = "up";
else if(window.event.keyCode == 38)
direction = "down";
else return; if(!obj.getAttribute("Index"))
return ;
var nextIndex = direction == "up" ? (~~obj.getAttribute("Index"))--
: (~~obj.getAttribute("Index"))++; var inputList = document.getElementsByTagName("input");
for(var i=0 ; i<inputList.length;i++){
if(inputList[i].getAttribute("Index") == nextIndex){
inputList[i].focus();
}
}
}
//这是思路,具体的逻辑还要自己写
时间戳: Thu, 19 Aug 2010 06:19:53 UTC
消息: 不能给 '[number: 2]' 赋值
行: 16
字符: 5
代码: 0
URI: file:///C:/Users/Administrator/Desktop/gh%20fs.html有错误....
var inputList = document.getElementsByTagName("input");
for(var i=0 ; i<inputList.length;i++){
if(inputList[i].getAttribute("Index") == nextIndex){
inputList[i].focus();
}
}你可以讲一讲这一段代码的意思给我听听吗?
我现在还没有去测试
不过我的解理,
var inputList = document.getElementsByTagName("input"); // 找到页面所有input元素
for(var i=0 ; i<inputList.length;i++){ //遍历元素的 Index属性
if(inputList[i].getAttribute("Index") == nextIndex){ //如果属性名相吻合
inputList[i].focus(); //把焦点给这个控件
}
}
对吗?
谢谢啦,现在可以啦!但是有一个问题!
var nextIndex = direction == "up" ? (~~obj.getAttribute("Index"))--
: (~~obj.getAttribute("Index"))++;
这一句应该改成
var nextIndex = direction == "up" ? (~~obj.getAttribute("Index"))-1
: (~~obj.getAttribute("Index"))+1;
这样系统才不会报错!用++ -- 系统会提示无法给 number:1 赋值