我用了一个input(button)需要用它实现重置功能!
请问应该怎样实现
代码:<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input id="Button1" type="button" value="重置" />
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>目的:点击Button1可以使TextBox1.text,TextBox2.text为空
请问应该怎样实现
代码:<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input id="Button1" type="button" value="重置" />
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>目的:点击Button1可以使TextBox1.text,TextBox2.text为空
干什么非要用input的啊???
Text1.value="";
Text2.value="";
}
或直接使用
<input id="Button1" type="reset" value="重置" />
-_-! 到是方便,服务器方法和客户端一起用!!!document.getElementById("TextBox1").value = '';
function clearFun()
{
document.getElementById("TextBox1").value = "";
document.getElementById("TextBox2").value = "";
}
</script>
<td>
<input id="Button1" type="button" onclick="clearFun()" value="重置" />
</td>
上面是客户端脚本实现
function Button1_onclick() {
Text1.value="";
Text2.value="";
}
我尝试过几次都不行把Text1改为TextBox1,Text1改为TextBox1---这样也不行!!不知道是不是还有什么地方出现问题而我没有发现·!!!感觉比较好的是:
<script>
function clearFun()
{
document.getElementById("TextBox1").value = "";
document.getElementById("TextBox2").value = "";
}
</script>
<td>
<input id="Button1" type="button" onclick="clearFun()" value="重置" />
</td>