1.我有一个带有2个复选框列和一个文本框列的模板字段的网格视图. 我需要JavaScript来切换复选框中的检查状态(即,我有2个名称为chkapprove和chkreject的复选框,如果我选中"chkapprove",则"chkreject"应取消选中它是否已被选中,反之亦然) 2.我需要在chkreject检查,并没有什么在文本框中输入其具有与味精进入理性"警报按钮点击功能..
1. i have a grid view with template fields with 2 checkbox column and a textbox column. i need javascript to toggle the check status in the checkboxes(i.e i hav 2 checkbox with name chkapprove and chkreject, if i check "chkapprove" then "chkreject" should uncheck if it is already checked and vice versa) 2. i need a button click function which has to alert with msg "Enter the reason" when chkreject is checked and nothing is entered in the text box..
function reason() { MyGridView = document.getElementById('<%= grdaccess.ClientID %>'); var Inputs = MyGridView.getElementsByTagName("input"); var chkBox = "Chkreject"; var textbox = "txtreason"; for (var n = 0; n < Inputs.length; ++n) if (Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(chkBox, 0) >= 0 && Inputs[n].checked) if (Inputs[n+1].type == 'textbox' && Inputs[n+1].id.indexOf(textbox, 0) >= 0 && Inputs[n+1].length <= 0) { alert("enter the reason"); return false; } return true; }<asp:Button ID="btnSubmit" runat="server" CssClass="showall" Text="Submit" OnClientClick="javascript:return reason();" onclick="btnsubmit_Click" />
这是我为条件2编写的代码.但它不起作用. 这是我的html代码: 有人可以帮我吗?
this is the code i have written for condition 2 . but its not working. this is my html code: can someone help me with this ?
<asp:GridView ID="grdaccess" runat="server" CssClass="mGridv" AutoGenerateColumns="False" AllowPaging="True" CellPadding="4" BackColor="White" PagerSettings-PageButtonCount="5" PagerSettings-Mode= "NumericFirstLast" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" GridLines="Horizontal" EnableViewState="false" onrowdatabound="grdaccess_RowDataBound" onpageindexchanging="grdaccess_PageIndexChanging" > <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <HeaderStyle CssClass="first" Font-Bold="true" /> <PagerStyle CssClass="pgr" ></PagerStyle> <RowStyle CssClass="odd" /> <AlternatingRowStyle CssClass="even" BackColor ="White" /> <Columns> <asp:TemplateField HeaderText="Case Study Name"> <ItemTemplate> <asp:LinkButton ID ="lbcsname" runat ="server" OnClick="lnkCustomer_Click" ></asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Esa Project"> <ItemTemplate> <asp:Label ID="lblprojects" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="WorkFlow"> <ItemTemplate> <asp:LinkButton runat="server" ID="lnkworkflowhistory" OnClick="lnkworkflow_click"> </asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="DeliveryManager"> <ItemTemplate> <asp:Label ID="lbldeliverymanager" CssClass="leftalign" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Client"> <ItemTemplate> <asp:Label ID="lblclient" CssClass="leftalign" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Status" Visible="false"> <ItemTemplate> <asp:Label ID ="lbstatus" runat ="server" ></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Approve" ItemStyle-HorizontalAlign="Center" > <ItemTemplate> <asp:CheckBox ID="Chkapprove" runat="server" AutoPostBack="true" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Reject" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:CheckBox ID="Chkreject" runat="server" AutoPostBack="true" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Remarks"> <ItemTemplate> <asp:TextBox ID="txtreason" runat="server"></asp:TextBox> </ItemTemplate> </asp:TemplateField> </Columns> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <SortedAscendingCellStyle BackColor="#F4F4FD" /> <SortedAscendingHeaderStyle BackColor="#5A4C9D" /> <SortedDescendingCellStyle BackColor="#D8D8F0" /> <SortedDescendingHeaderStyle BackColor="#3E3277" /> </asp:GridView> <asp:Button ID="btnSubmit" runat="server" CssClass="showall" Text="Submit" OnClientClick="javascript:return reason();" onclick="btnsubmit_Click" />预先感谢, gowrishankar
thanks in advance , gowrishankar
推荐答案尝试使用输入[n + 1] .type =="text" Try to use Inputs[n+1].type == ''text''
更多推荐
在gridview中的复选框之间切换复选框.
发布评论