当光标从文本框中移出时 [英] when curser mouseout from the textbox

查看:70
本文介绍了当光标从文本框中移出时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框,其中包含员工编号.
当光标从该文本框中退出(鼠标移出)时,我希望此雇员的姓名出现在另一个文本框中.

我该怎么办?

I have a textbox that will take the employee number.
When the curser out (mouseout) from this textbox I want the name of this employee to appear in another textbox.

What can I do please?

推荐答案

您为此使用了错误的事件.正确的选择是TextChanged或LostFocus.您只需处理这些事件之一,然后启动填写其他TextBox所需的代码.
You''re using the wrong event for this. The correct choices would be either TextChanged or LostFocus. You just handle one of those events and kick off the code you need to to fill in the other TextBox.


输入文本时,我总是将鼠标光标移开,所以这是一个糟糕的设计.仅当当前控件失去焦点(或按下按钮)时,才应更新其他控件,因此此时,您将需要处理LostFocus事件或Leave事件.
I always move the mous cursor out of the way when I''m entering text, so that''s a bad design. You should only update other controls when the current control looses focus (or a button is pushed), so at that point, you''d need to handle either the LostFocus event, or the Leave event.


您可以使用JavaScript处理文本框的mouseout事件,然后提取值并用它填充另一个文本框. jQuery将使其中的一些操作变得更容易.
You can use JavaScript to handle the mouseout event for the textbox then extract the value and populate the other textbox with it. JQuery will make some of this easier.


这篇关于当光标从文本框中移出时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆