clear the other two controls if third controls value changes — using Javascript
I have two textBoxes and a checkBox
txtExpiryDate–with ajaxCalenderExtender
txtDaysToExpire
chkExpired –checkbox
The issue that I cannot fix is, if the value in any of the above three controls is changed (on client side) the other two should be cleared..
Like if a date is selected in txtExpiryDate, values of other two controls should be cleared to: txtDaysToExpire.Text=""; and chkExpired.Checked = false .. and similarly if chkExpired.Checked = true, then other two should be cleared.. Hope it makes it clear to understand.. Please have a look at the mark-up
<td colspan="2" rowspan="2">
<asp:UpdatePanel ID="upnlExpiry" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtExpiryDate" EventName="TextChanged" />
<asp:AsyncPostBackTrigger ControlID="txtDaysToExpire" EventName="TextChanged" />
<asp:AsyncPostBackTrigger ControlID="chkExpired" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="leftaligntxt">
<tr>
<td width="44%" align="left">
Expiry Date
</td>
<td colspan="2">
<asp:TextBox ID="txtExpiryDate" runat="server" OnTextChanged="txtExpiryDate_TextChanged"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="calExtExpiryDate" runat="server" Format="dd/MM/yyyy"
PopupButtonID="imgBtnCal" TargetControlID="txtExpiryDate">
</ajaxToolkit:CalendarExtender>
<asp:ImageButton ID="imgBtnCal" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/App_Themes/FQBlue/img/Calendar_img.png" />
</td>
</tr>
<tr>
<td width="44%">
Days to Expire
</td>
<td valign="top">
<asp:TextBox ID="txtDaysToExpire" runat="server" Width="80px" OnTextChanged="txtDaysToExpire_TextChanged"
></asp:TextBox>
<ajaxToolkit:NumericUpDownExtender ID="txtDaysToExpire_NumericUpDownExtender" runat="server"
Maximum="15000" Minimum="0" TargetControlID="txtDaysToExpire" Width="100">
</ajaxToolkit:NumericUpDownExtender>
</td>
<td>
<asp:CheckBox ID="chkExpired" runat="server" Text="Show Expired" AutoPostBack="True"
OnCheckedChanged="chkExpired_CheckedChanged" />
</td>
</tr>
<tr>
<td>
</td>
<td colspan="2">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
@Ashwini Your code with the following code worked fine for me..
because it was that all the three should clear other two and checkbox was not working the way I needed with above code..so had to go other way round.. Anyways following code worked fine for me..
Now it clears both of the not selected ( among the three controls)
Thank-you once again..!