如何操作小键盘的上下键应用在td上 就是说像google中那样,能匹配搜索的字符用小键盘上的上、下键移动付给文本输入框 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 只要得到tbody中的td的文本就行。请教! 在当前项,使用onkeyup,对输入的键进行判断,如果是按下上或者下键的话,使上或者下行选中. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head> <title>Bug</title> <script> var tdIndex = 1; function change(){ if(event.keyCode==40){ tdIndex+=1; eval("document.all.td"+tdIndex+".style.backgroundColor='#3366aa'"); document.all.txt.value = eval("document.all.td"+tdIndex+".innerText"); }//down } </script></head><body onkeydown="change()" ><table border='1' bordercolor="#FFFFFF"><tr><td id="td1">one</td></tr><tr><td id="td2">two</td></tr><tr><td id="td3">three</td></tr><tr><td id="td4">four</td></tr><tr><td id="td5">five</td></tr></table><input type="text" value="" id="txt"></body></html>没时间了 做了一下 你参考完成以后的吧 <html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <script language="javascript"> window.document.onkeydown=test; function $(o) { return document.getElementById(o); } var currentFocus={y:0}; function test() { if(event.keyCode==38 && currentFocus.y>0) { currentFocus.y--; } if(event.keyCode==40 && currentFocus.y<$("table1").rows.length-1) { currentFocus.y++; } for(i=0;i<$("table1").rows.length;i++) { var tempBgColor=$("table1").rows[i].cells[0].bgColor if(i==currentFocus.y) { $("table1").rows[i].cells[0].bgColor="#00ff00"; } else { $("table1").rows[i].cells[0].bgColor=""; } } $("input1").value=$("table1").rows[currentFocus.y].cells[0].innerText; } </script> </head> <body> <table border="1" width="100%" id="table1" height="320"> <tr> <td style="width:33%;"> 123123</td> <tr> <td style="width:33%;"> asdfasdfa</td> </tr> <tr> <td style="width:33%;"> baa2424234234</td> </tr> </table> <input type="text" id="input1"> </body></html>是这种效果吗? 找到国人开发的,基于extjs以及extjs的开源电子商务系统 iframe问题 js引入没有反映 连alert都没有反映 帮忙看一下,第一次用js 这两个程序片段是什么意思 关于动态添加元素属性的问题(在线等...) Javascript诞生记-C和Self语言一夜情的产物 请教怎么样让光驱通过程序自动弹出和关闭??up有分 送分! 好久没来了,也散一贴,中秋快乐 document.captureEvents(Event.CLICK) 出错??!! 简单问题_和onclick与链接有关 javascript取得焦点和失去焦点
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Bug</title>
<script>
var tdIndex = 1;
function change(){
if(event.keyCode==40){
tdIndex+=1; eval("document.all.td"+tdIndex+".style.backgroundColor='#3366aa'");
document.all.txt.value = eval("document.all.td"+tdIndex+".innerText");
}//down }
</script>
</head>
<body onkeydown="change()" >
<table border='1' bordercolor="#FFFFFF">
<tr>
<td id="td1">one</td>
</tr>
<tr>
<td id="td2">two</td>
</tr>
<tr>
<td id="td3">three</td>
</tr>
<tr>
<td id="td4">four</td>
</tr>
<tr>
<td id="td5">five</td>
</tr>
</table>
<input type="text" value="" id="txt">
</body>
</html>没时间了 做了一下 你参考完成以后的吧
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<script language="javascript">
window.document.onkeydown=test;
function $(o)
{
return document.getElementById(o);
}
var currentFocus={y:0};
function test()
{
if(event.keyCode==38 && currentFocus.y>0)
{
currentFocus.y--;
}
if(event.keyCode==40 && currentFocus.y<$("table1").rows.length-1)
{
currentFocus.y++;
}
for(i=0;i<$("table1").rows.length;i++)
{
var tempBgColor=$("table1").rows[i].cells[0].bgColor
if(i==currentFocus.y)
{
$("table1").rows[i].cells[0].bgColor="#00ff00";
}
else
{
$("table1").rows[i].cells[0].bgColor="";
}
}
$("input1").value=$("table1").rows[currentFocus.y].cells[0].innerText; }
</script>
</head>
<body>
<table border="1" width="100%" id="table1" height="320">
<tr>
<td style="width:33%;"> 123123</td>
<tr>
<td style="width:33%;"> asdfasdfa</td>
</tr>
<tr>
<td style="width:33%;"> baa2424234234</td>
</tr>
</table>
<input type="text" id="input1">
</body>
</html>
是这种效果吗?