怎样清空页面中TextBox里的值,要用javascript脚本写,请给个例子,谢谢!!!

解决方案 »

  1.   

    document.getElemeteById('id').innerText = "";
    是要这样的吗?
      

  2.   

    document.getElemeteById('id').value = "";
      

  3.   

    <script type="text/javascript">
    function clearTextBox(id)
    {
        document.getElemeteById(id).value = "";
    }
    </script>
      

  4.   

    <script type="text/javascript">
    function a()
    {
         var txt = document.getElementById('TextBox1');  
         txt.value=""; }</script><body>
        <form id="form1" runat="server">
        <div>
            &nbsp;</div>
            <asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="a()"/>
        </form>
    </body>
    </html>
    要怎么改?????????????
      

  5.   

    <script type="text/javascript">
    function clearTextBox(id)
    {
        document.getElemeteById(id).value = "";
    }
    </script>
      

  6.   

    document.getElemeteById('id').value = "";
      

  7.   

    晕了
    <script type="text/javascript">
    function a()
    {
    var txt = document.getElementById('TextBox1');
    txt.value="";}</script><body>
    <form id="form1" runat="server">
    <div>
    &nbsp;</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>
      

  8.   

    我晕了,就说下面的代码为什么会报不包含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>
            &nbsp;</div>
            <asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="a()"/>
        </form>
    </body>
    </html>
      

  9.   

    在后台写就可以了
    把<asp:Button ID="Button1" runat="server" Text="Button" OnClick="a()"/>中的OnClick="a()"放在后台写
    例:Button1.Attributes.Add("onclick", "javascript:a()");
    这样就可以了,试试吧!我试成功了!!!
      

  10.   

    在我的开发中,“清除页面上的TextBox”这种描述太“大胆”了,不可能被一个负责的管理者说出。页面上随时可能需要根据逻辑需求而增加一些东西,管理者承担了保证项目平稳扩展的责任,所以不可能乱说。
      

  11.   

    <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>
            &nbsp;</div>
            <asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return a()"/>
        </form>
    </body>
    </html>这样试试
      

  12.   

    如果onClientCliek里写成return a();
    那JS函数里最好还是这样
    <script type="text/javascript">
    function a()
    {
    document.getElementById('TextBox1').value="";
    return false;}</script>
      

  13.   

    <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