当我在文本框上输入内容时,复选框会自动检查 [英] Checkbox auto check when i input something on textbox

查看:70
本文介绍了当我在文本框上输入内容时,复选框会自动检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员在这里遇到了问题.我想知道ASP.NEt是否可以在复选框和文本框之间创建链接,其中在填充文本框时复选框会自动检查自身,而在清空文本框时复选框会取消选中

请给我有关此事的教程

谢谢,还有更多功能.

Hello programmers, got a problem here. I would like to know if ASP.NEt can create a link between checkbox and textbox where the checkbox will autocheck itself when textbox is filled and the checkbox unchecked when the textbox is being emptied

plss give me tutorial regarding this matter

Thanks and more power

推荐答案

ASP.NET创建HTML和javascript,可以做到这一点.您需要处理文本框内的按键事件,然后检查要检查或取消选中的文本的长度.使用两个控件的ClientID属性发出javascript,以将其添加到页面中.
ASP.NET creates HTML and javascript, which can do this. You need to handle the event of a keypress inside the textbox, and then check the length of the text to check or uncheck. Use the ClientID property of your two controls to emit javascript to do this in to your page.


这是JavaScript代码
函数check()
{
document.GetElementById("checkboxname").checked = true;
}

在甚至文本框的OnKeyPress或OnKeyDown上调用此方法

< asp:TextBox ID ="txt1" OnKeyPress ="check" OnKeyDown ="check" runat ="server">
this is javascript code
function check()
{
document.GetElementById("checkboxname").checked = true ;
}

call this method on OnKeyPress or OnKeyDown even of the Textbox

<asp:TextBox ID="txt1" OnKeyPress ="check" OnKeyDown ="check" runat="server">


这篇关于当我在文本框上输入内容时,复选框会自动检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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