jQuery代码,用于连接用于搜索的id
我想对我单击的行控件执行一些操作,当jQuery代码,用于连接用于搜索的id,jquery,asp.net,Jquery,Asp.net,我想对我单击的行控件执行一些操作,当txtitemDesc和txtitemAmnt是1时,我所有的代码都工作正常,但是当我尝试用rowindex连接txtitemDesc时,代码中没有显示任何情况 $("document").ready(function () { $("[id$=tblorder]").find('tr').click(function () { var rowindex = $(this).index() ;
txtitemDesc
和txtitemAmnt
是1
时,我所有的代码都工作正常,但是当我尝试用rowindex
连接txtitemDesc
时,代码中没有显示任何情况
$("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>
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>
$(函数(){
$(“[id$=txtdate]”。日期选择器({
showOn:'按钮',
buttonImageOnly:正确,
buttonImage:'images/calender.png',
日期格式:“dd-mm-yy”
});
$(“[class$=hiddentextbox]”)css('display','none');
$(“[id$=tblorder]tr”)。不是(':first')。悬停(
函数(){
$(this.css(“背景”、“蓝色”);
},函数(){
$(this.css(“背景”和“”);
});
});
$(“文档”).ready(函数(){
$(“[id$=tblorder]”。查找('tr')。单击(函数(){
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');
}
其他的
{
$(“[id$=txtItemDesc]”+rowindex.css('display','none');
$(“[id$=txtItemAmnt]”+rowindex.css('display','none');
};
});
});
从$(文档)开始。
问题区域是$(“[id$=txtItemDesc]”)。id
您可以共享HTML吗?给定文本框的控件id是什么?@hdkhardik第一个文本框的id是txtItemDesc1,第二个文本框是第一行的txtitemnt1,在每一个新行它都变成txtItemDesc2和txtitemnt2,依此类推。。
<%@ 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>