我想对我点击的行控件执行一些操作,当txtitemDesc
和txtitemAmnt
为1
时,我的所有代码都正常工作但是当我尝试连接时txtitemdesc
1}}和txtitemamnt
rowindex
没有任何反应,如代码所示
$("document").ready(function () {
$("[id$=tblorder]").find('tr').click(function () {
var rowindex = $(this).index() ;
if ($(event.target).is(":checkbox") && $(event.target).is(":checked")) {
$("[id$=txtItemDesc]" + rowindex).css('display', 'inline');
$("[id$=txtItemAmnt]" + rowindex).css('display', 'inline');
}
else
{
$("[id$=txtItemDesc]" + rowindex).css('display', 'none');
$("[id$=txtItemAmnt]" + rowindex).css('display', 'none');
};
});
});
</script>
我尝试了以下操作但警报值为NaN
$("document").ready(function () {
$("[id$=tblorder]").find('tr').click(function () {
var rowindex = $(this).index() ;
if ($(event.target).is(":checkbox") && $(event.target).is(":checked")) {
var totalId1 = $("[id$=txtItemDesc]").ID + rowindex;
var totalId2 = $("[id$=txtItemAmnt]").id + rowindex;
alert(totalId1);
alert(totalId2);
$(totalId1).css('display', 'inline');
$(totalId2).css('display', 'inline');
}
else
{
$(totalId1).css('display', 'none');
$(totalId2).css('display', 'none');
};
});
});
html页面是
<%@ Page Title="" Language="C#" MasterPageFile="~/mstr-homepage.master" AutoEventWireup="true" CodeFile="frm-civilwork.aspx.cs" Inherits="frm_civilwork" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
$(function () {
$("[id$=txtdate]").datepicker({
showOn: 'button',
buttonImageOnly: true,
buttonImage: 'images/calender.png',
dateFormat: 'dd-mm-yy'
});
$("[class$=hiddentextbox]").css('display', 'none');
$("[id$=tblorder] tr").not(':first').hover(
function () {
$(this).css("background", "blue");
}, function () {
$(this).css("background", "");
});
});
$("document").ready(function () {
$("[id$=tblorder]").find('tr').click(function () {
var rowindex = $(this).index() ;
if ($(event.target).is(":checkbox") && $(event.target).is(":checked")) {
$("[id$=txtItemDesc]" + rowindex).css('display', 'inline');
$("[id$=txtItemAmnt]" + rowindex).css('display', 'inline');
}
else
{
$("[id$=txtItemDesc]" + rowindex).css('display', 'none');
$("[id$=txtItemAmnt]" + rowindex).css('display', 'none');
};
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table id="tblorder" align="center" class="auto-style3" border="1">
<tr>
<td class="auto-style9">
<asp:Label ID="label11" runat="server" Text="Order Number : "></asp:Label>
<asp:Label ID="lblorderno" runat="server" Text="" ></asp:Label>
</td>
<td><asp:Label ID="Label2" runat="server" Text="Enter item description"></asp:Label></td>
<td class="auto-style8"><asp:Label ID="Label1" runat="server" Text="Amount"></asp:Label></td>
</tr>
<tr id="1">
<td class="auto-style12">
<asp:CheckBox ID="chkCoat" Text="Coat" runat="server" />
</td>
<td class="auto-style13">
<asp:TextBox ID="txtItemDesc1" class="hiddentextbox" runat="server" Width="381px"></asp:TextBox>
</td>
<td class="auto-style14">
<asp:TextBox ID="txtItemAmnt1" class="hiddentextbox" runat="server" Width="106px"></asp:TextBox>
</td>
</tr>
<tr id="2">
<td class="auto-style5">
<asp:CheckBox ID="chkShirt" Text="Shirt" runat="server" />
</td>
<td class="auto-style6">
<asp:TextBox ID="txtItemDesc2" class="hiddentextbox" runat="server" Width="381px"></asp:TextBox>
</td>
<td class="auto-style15">
<asp:TextBox ID="txtItemAmnt2" class="hiddentextbox" runat="server" Width="106px"></asp:TextBox>
</td>
</tr>
<tr id="3">
<td class="auto-style5">
<asp:CheckBox ID="chkPant" Text="Pant" runat="server" />
</td>
<td class="auto-style6">
<asp:TextBox ID="txtItemDesc3" class="hiddentextbox" runat="server" Width="381px"></asp:TextBox>
</td>
<td class="auto-style15">
<asp:TextBox ID="txtItemAmnt3" class="hiddentextbox" runat="server" Width="106px"></asp:TextBox>
</td>
</tr>
<tr id="4">
<td class="auto-style5">
<asp:CheckBox ID="chksherwani" Text="Serwani" runat="server" />
</td>
<td class="auto-style6">
<asp:TextBox ID="txtItemDesc4" class="hiddentextbox" runat="server" Width="381px"></asp:TextBox>
</td>
<td class="auto-style15">
<asp:TextBox ID="txtItemAmnt4" class="hiddentextbox" runat="server" Width="106px"></asp:TextBox>
</td>
</tr>
<tr id="5">
<td class="auto-style5">
<asp:CheckBox ID="chkmodijacket" Text="Modijacket" runat="server" />
</td>
<td class="auto-style6">
<asp:TextBox ID="txtItemDesc5" class="hiddentextbox" runat="server" Width="381px"></asp:TextBox>
</td>
<td class="auto-style15">
<asp:TextBox ID="txtItemAmnt5" class="hiddentextbox" runat="server" Width="106px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style16">
</td>
<td style="text-align: right">
<asp:Label ID="lbltotalamnt" runat="server" Text="Total amount:"></asp:Label>
</td>
<td class="auto-style18">
<asp:Label ID="lbldisplaytotal" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style9"></td>
<td style="text-align: right">
<asp:Label ID="Label3" runat="server" Text="Amount Paid"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtamntpaid" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style9">
<asp:Label ID="Label12" runat="server" Text="description(*optional)"></asp:Label>
</td>
<td style="text-align: right;">
<asp:TextBox ID="txtdescription" runat="server" Width="300px" style="margin-left: 0px"></asp:TextBox><no br />
<asp:Label ID="Label13" runat="server" Text="Balance" ></asp:Label>
</td>
<td>
<asp:Label ID="lblbalance" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style9"></td>
<td>
<asp:Label ID="Label4" runat="server" Text="select delevery date"></asp:Label>
<asp:TextBox ID="txtdate" runat="server"></asp:TextBox>
</td>
<td class="auto-style8">
<asp:Button ID="btnsave" runat="server" Text="Save" Width="92px" OnClick="btnsave_Click" />
</td>
</tr>
</table>
</table>
</asp:Content>