先幫我解決按向上鍵怎么使光標向上的問題。
我現在能用下面的代碼使光標在自動生成的几行input里向下跳﹕
function init(){
var ta=document.all.abcde;
for(var i=0;i<100;i++){
if(document.getElementById("abcde"+i)!=null) {
document.getElementById("abcde"+i).onkeydown=function (){
if(event.keyCode == 40){
var textid=Number(this.id.substring(5,this.id.length))+1;
if(textid<100) document.getElementById("abcde"+textid).focus(); }
} } } }
請問怎么使按向上鍵時光標向上跳﹖
我現在能用下面的代碼使光標在自動生成的几行input里向下跳﹕
function init(){
var ta=document.all.abcde;
for(var i=0;i<100;i++){
if(document.getElementById("abcde"+i)!=null) {
document.getElementById("abcde"+i).onkeydown=function (){
if(event.keyCode == 40){
var textid=Number(this.id.substring(5,this.id.length))+1;
if(textid<100) document.getElementById("abcde"+textid).focus(); }
} } } }
請問怎么使按向上鍵時光標向上跳﹖
var textid=Number(this.id.substring(5,this.id.length))-1;//你把这个改成-1就上跳了嘛
if(textid>=0) document.getElementById("abcde"+textid).focus
var ta=document.all.abcde;
for(var i=0;i<100;i++){
if(document.getElementById("abcde"+i)!=null) {
document.getElementById("abcde"+i).onkeydown=function (){
if(event.keyCode == 40){
var textid=Number(this.id.substring(5,this.id.length))+1;
if(textid<100) document.getElementById("abcde"+textid).focus(); }
} } }
for(var j=100;j>=0;j--){
if(document.getElementById("abcde"+j)!=null) {
document.getElementById("abcde"+j).onkeydown=function (){
if(event.keyCode == 38){
var textid2=Number(this.id.substring(5,this.id.length))-1;
if(textid2>=0) document.getElementById("abcde"+textid2).focus(); }
} } }
}
這樣寫為何只能向上跑﹐不能向下跑了。
var textid=Number(this.id.substring(5,this.id.length))+1;
if(textid<100) document.getElementById("abcde"+textid).focus(); }
if(event.keyCode == 38){
var textid2=Number(this.id.substring(5,this.id.length))-1;
if(textid2>=0) document.getElementById("abcde"+textid2).focus(); }
} } } }
哦﹐改為這樣就可以了﹐謝。怎么使提交后得到的頁面的某一input默認得到光標焦點﹖
/*form2.abcde0.focus();*/
document.all.abcde0.focus();
</script>不能設默認焦點了。
如果可用普通頁面實現功能就不需用框架去弄。