先生/女士
我将创建一个带有重置按钮的表单,该按钮可以清除表单的字段
但功能无法正常工作。在框中输入的先前记录仍在此处。 您能告诉方法清除客户端的表格吗?
以下是我的代码:
<script type="text/javascript">
...
function ClearForms(sender, args) {
document.getElementById('<%=txtRemeasureCode.ClientID%>').innerText() = "";
document.getElementById('<%=dapSubmitTo.ClientID%>').clear();
document.getElementById('<%=dapSubmitFrom.ClientID%>').clear();
}
.. .
<telerik:RadTextBox ID="txtRemeasureCode" Width="200px" runat="server" AutoPostBack="false" />
....
<telerik:RadDatePicker ID="dapSubmitFrom" runat="server" MinDate="2010-01-01" AutoPostBack="false" Width="200px">
<Calendar ID="CalendarFrom" RangeMinDate="2010-01-01" runat="server">
</Calendar>
<DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
<DateInput DisplayDateFormat="yyyy-M-d" DateFormat="yyyy-M-d" runat="server" ></DateInput>
</telerik:RadDatePicker>
.....
<telerik:RadDatePicker ID="dapSubmitTo" runat="server" MinDate="2010-01-01" AutoPostBack="false" Width="200px">
<Calendar ID="CalendarTo" RangeMinDate="2010-01-01" runat="server">
</Calendar>
<DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
<DateInput DisplayDateFormat="yyyy-M-d" DateFormat="yyyy-M-d" runat="server"></DateInput>
</telerik:RadDatePicker>
...........
..............
<telerik:RadButton ID="btnReset" runat="server" Text="Reset" OnClientClick="ClearForms;return false">
<Icon PrimaryIconUrl="~/Image/Button/reset.gif" PrimaryIconLeft="4" PrimaryIconTop="4" />
</telerik:RadButton>
答案 0 :(得分:1)
这是有效的代码:
<telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="SelectedIndexChanged" >
<Items>
<telerik:RadComboBoxItem Value="0" Text="" />
<telerik:RadComboBoxItem Value="1" Text="One" />
<telerik:RadComboBoxItem Value="2" Text="Two" />
<telerik:RadComboBoxItem Value="3" Text="Three" />
</Items>
</telerik:RadComboBox>
<telerik:RadTextBox ID="RadTextBox1" runat="server" />
<asp:Button ID="btnClear" runat="server" OnClientClicked="ClearValues();return false;" Text="Clear" />
<script type="text/javascript">
function SelectedIndexChanged(sender, args)
{
if (args.get_item().get_value() != 0)
{
var textBoxNewValue = args.get_item().get_value() + ": " + args.get_item().get_text();
$find("<%= RadTextBox1.ClientID %>").set_value(textBoxNewValue);
}
else
{
$find("<%= RadTextBox1.ClientID %>").clear();
}
}
function ClearValues()
{
$find("<%= RadTextBox1.ClientID %>").clear();
$find("<%= RadComboBox1.ClientID %>").clearSelection();
}
</script>