日期:2014-05-18  浏览次数:20425 次

点击textbox焦点切换到button
页面有多个textbox、button,点击textbox1切换到button1、以此类推。

注意是首先是点击textbox1切换到button1,不是回车以后执行button1的click,当然了,回车的时候当然要执行button1的click不能使button2的了。

javascrpit,不要用C#,thx!!

------解决方案--------------------
在TextBox單擊事件中
{
button.Focus();
}

先占個沙發再說``
------解决方案--------------------
有点输入错误,看下面的.
<INPUT TYPE= "text " onfocus= "alert( 'a ');document.all.button1.focus(); "> <INPUT TYPE= "button " id= 'button1 ' value= 'a '>
------解决方案--------------------
需求比较奇怪 <asp:textbox onclick= "javascript:document.getElementById(this.id.replace( 'textbox ', 'button ')).click "
------解决方案--------------------
如果确实有非常多的textbox和button,并且它们排列有一定规则,比如一一配对,那可以写一个公用的js函数,所有textbox的onclick均调用这个函数即可。比如:
<asp:TextBox id= "txt1 " .. OnClientClick= "pub(this); " /> <asp:Button id= "btn1 " .. />
<asp:TextBox id= "txt2 " .. OnClientClick= "pub(this); "/> <asp:Button id= "btn2 " .. />
<asp:TextBox id= "txt3 " .. OnClientClick= "pub(this); "/> <asp:Button id= "btn3 " .. />
......

function pub(e)
{
document.getElementById( "btn " + e.id.substring(3,e.id.length)).focus();
}
------解决方案--------------------

<INPUT TYPE= "text " onfocus= "onfucos= "document.all.button1.fucos; ">
------解决方案--------------------
onfucos= "document.all.button1.fucos; "