关于清空页面中TextBox里的值 怎样清空页面中TextBox里的值,要用javascript脚本写,请给个例子,谢谢!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.getElemeteById('id').innerText = "";是要这样的吗? document.getElemeteById('id').value = ""; <script type="text/javascript">function clearTextBox(id){ document.getElemeteById(id).value = "";}</script> <script type="text/javascript">function a(){ var txt = document.getElementById('TextBox1'); txt.value=""; }</script><body> <form id="form1" runat="server"> <div> </div> <asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" onclick="a()"/> </form></body></html>要怎么改????????????? <script type="text/javascript">function clearTextBox(id){ document.getElemeteById(id).value = "";}</script> document.getElemeteById('id').value = ""; 晕了<script type="text/javascript">function a(){var txt = document.getElementById('TextBox1');txt.value="";}</script><body><form id="form1" runat="server"><div> </div><asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox><asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="a();return false;"/></form></body></html> 我晕了,就说下面的代码为什么会报不包含a的定义,要怎样改????<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title></head><script type="text/javascript">function a(){ document.getElementById('TextBox1').value=""; }</script><body> <form id="form1" runat="server"> <div> </div> <asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="a()"/> </form></body></html> 在后台写就可以了把<asp:Button ID="Button1" runat="server" Text="Button" OnClick="a()"/>中的OnClick="a()"放在后台写例:Button1.Attributes.Add("onclick", "javascript:a()");这样就可以了,试试吧!我试成功了!!! 在我的开发中,“清除页面上的TextBox”这种描述太“大胆”了,不可能被一个负责的管理者说出。页面上随时可能需要根据逻辑需求而增加一些东西,管理者承担了保证项目平稳扩展的责任,所以不可能乱说。 <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title></head><script type="text/javascript">function a(){ document.getElementById('TextBox1').value=""; }</script><body> <form id="form1" runat="server"> <div> </div> <asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return a()"/> </form></body></html>这样试试 如果onClientCliek里写成return a();那JS函数里最好还是这样<script type="text/javascript">function a(){document.getElementById('TextBox1').value="";return false;}</script> <script type="text/javascript"> function a() { var texts=document.getElementById("text"); texts.value=""; return false; }然后改<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="a()"/>注意是OnClientClick不是OnClick MVC的问题,高手请进! Asp.net网站中能不能添加Access数据库,如何添加? asp.net2.0服务器配置 关于类里面局部变量的问题。 asp.net 中如何创建数字证书 安全性异常 System.Security.SecurityException 又不会了,求教! 菜鸟提问! 江湖救急~请问如何移植ASP.NET网站?把朋友的ASP.NET源代码移植到本机? 页面现实问题 如何在DropDownList中显示这样的效果 刚才浏览CSDN这个页面瑞星报告有病毒
是要这样的吗?
function clearTextBox(id)
{
document.getElemeteById(id).value = "";
}
</script>
function a()
{
var txt = document.getElementById('TextBox1');
txt.value=""; }</script><body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="a()"/>
</form>
</body>
</html>
要怎么改?????????????
function clearTextBox(id)
{
document.getElemeteById(id).value = "";
}
</script>
<script type="text/javascript">
function a()
{
var txt = document.getElementById('TextBox1');
txt.value="";}</script><body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="a();return false;"/>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title></head><script type="text/javascript">
function a()
{
document.getElementById('TextBox1').value="";
}</script>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="a()"/>
</form>
</body>
</html>
把<asp:Button ID="Button1" runat="server" Text="Button" OnClick="a()"/>中的OnClick="a()"放在后台写
例:Button1.Attributes.Add("onclick", "javascript:a()");
这样就可以了,试试吧!我试成功了!!!
<head runat="server">
<title>无标题页</title></head><script type="text/javascript">
function a()
{
document.getElementById('TextBox1').value="";
}</script>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return a()"/>
</form>
</body>
</html>这样试试
那JS函数里最好还是这样
<script type="text/javascript">
function a()
{
document.getElementById('TextBox1').value="";
return false;}</script>
function a()
{
var texts=document.getElementById("text");
texts.value="";
return false;
}
然后改
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="a()"/>
注意是OnClientClick不是OnClick