(紧急)光标移动传值的问题!

两个Text框,我在Text1输入一个值后,按"Tab"键,光标移到下一个Text2框里,
我如何将Text1的值也传给Text2??

不是简单的document.all.text2.value=document.all.text1.value;

我只能获取当前点event.srcElement.name及其值event.srcElement.value。。。

我想用Tab Index获取下一个Index,知道其Name,再付给其值,但不知如何获得,怎样传值。
请高手解答!!
---------------------------------------------------------------

1<script>   
2function check(t){   
3var it=document.frm.elements   
4for(i=0;i<it.length;i++)if(it[i].tabIndex==t.tabIndex+1)it[i].value=t.value   
5}   
6</script>
1<form name="frm">
2<input onkeydown="if(event.keyCode==9)check(this)" tabindex="0"/>
3<input tabindex="3"/>
4<input tabindex="2"/>
5<input tabindex="1"/>
6</form>

---------------------------------------------------------------

1、tabIndex默认为0,tab键按对象创建顺序
所以tabIndex一般不可使用
2、可按下面的代码遍历对象,下一步再如何处理就自己决定吧

1<input name="text1" onfocus="test()" type="text"/>
1<input name="text2" onfocus="test()" type="text"/>
1<span id="view"></span>
 1<script>   
 2function test() {   
 3my = event.srcElement;   
 4el = my.parentElement.children;   
 5s = "";   
 6for(v in el)   
 7s += v+"=>"+el[v]+"<br>";   
 8view.innerHTML = s;   
 9}   
10</script>
Published At
Categories with Web编程
comments powered by Disqus