function GetSelectedMonth() {
var ControlRef = document.getElementById('<%= chkMonths.ClientID %>');
var CheckBoxListArray = ControlRef.getElementsByTagName('input');
var spanArray = ControlRef.getElementsByTagName('span');
var checkedValues = '';
for (var i = 0; i < CheckBoxListArray.length; i++) {
var checkBoxRef = CheckBoxListArray[i];
if (checkBoxRef.checked == true) {
var labelArray = checkBoxRef.parentNode.getElementsByTagName('label');
if (labelArray.length > 0) {
if (checkedValues.length > 0) {
checkedValues += ', ';
}
checkedValues += labelArray[0].innerHTML;
}
}
}
document.getElementById('<%= lbljsMonths.ClientID %>').innerHTML = checkedValues +" of "+ document.getElementById('<%=hfYear.ClientID%>').value;
};
function jsBankDetails() {
var bankName = document.getElementById('<%=txtBankName.ClientID %>');
var chequeNumber = document.getElementById('<%=txtChequeNumber.ClientID %>');
var chequeDate = document.getElementById('<%=txtChequeDate.ClientID %>');
var amount = document.getElementById('<%=txtCAmount.ClientID %>');
document.getElementById('<%=lbljsBankDetails.ClientID %>').innerHTML = bankName.innerHTML + " " + chequeNumber.innerHTML + " " + chequeDate.innerHTML + " " + amount.innerHTML;
};
function DisableEnable(ddlId) {
var controlName = document.getElementById(ddlId.id);
//var ddlPaymentMode = document.getElementById("<%=ddlPaymentMode.ClientID%>");
var bankName = document.getElementById("<%=txtBankName.ClientID%>");
var chequeNumber = document.getElementById("<%=txtChequeNumber.ClientID%>");
var chequeDate = document.getElementById("<%=txtChequeDate.ClientID%>");
var amount = document.getElementById("<%=txtCAmount.ClientID%>");
//var ddlText = ddlPaymentMode.options[ddlPaymentMode.selcetedIndex].innerHTML;
//if (ddlText == "Select PaymentMode" || ddlText == "Cash")
if (controlName.value == 0 || controlName.value == 1) {
bankName.value = "";
bankName.disabled = true;
chequeNumber.value = "";
chequeNumber.disabled = true;
chequeDate.value = "";
chequeDate.disabled = true;
amount.value = "";
amount.disabled = true;
}
else {
bankName.disabled = false;
chequeNumber.disabled = false;
chequeDate.disabled = false;
amount.disabled = false;
}
};
function printPanel() {
var panel = document.getElementById('<%=pnlFee.ClientID%>');
var printWindow = window.open('', '', 'height=550,width=450');
printWindow.document.write('<html><head><title>MYMANAGE.IN</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
};
<section id="secMonth" runat="server">
<fieldset>
<div class="alt two-thirds columns">
<asp:Label ID="lblMonth" Text="Months" runat="server"></asp:Label>
</div>
<asp:CheckBoxList ID="chkMonths" runat="server" RepeatDirection="Horizontal" onclick="GetSelectedMonth();"></asp:CheckBoxList>
</fieldset>
</section>
<section id="secBank" runat="server">
<fieldset>
<div class="alt two-thirds columns">
<asp:Label runat="server" ID="lblPaymentMode" Text="Payment Mode"></asp:Label>
<asp:DropDownList ID="ddlPaymentMode" runat="server" onchange="DisableEnable(this);">
<asp:ListItem Text="Select PaymentMode" Value="0"></asp:ListItem>
<asp:ListItem Text="Cash" Value="1"></asp:ListItem>
<asp:ListItem Text="Cheque" Value="2"></asp:ListItem>
</asp:DropDownList>
<%--<br />
<asp:CheckBox ID="chkCash" Text="Cash" runat="server" />
<asp:CheckBox ID="chkCheque" Text="Cheque" runat="server" />--%>
</div>
<div class="alt two-thirds columns" id="divBankName">
<asp:Label runat="server" ID="lblBankName" Text="Bank Name"></asp:Label>
<asp:TextBox runat="server" ID="txtBankName" onKeyUp="jsBankDetails();"></asp:TextBox>
</div>
<div class="alt two-thirds columns" id="divChequeNumber">
<asp:Label runat="server" ID="lblChequeNumber" Text="Cheque Number"></asp:Label>
<asp:TextBox runat="server" ID="txtChequeNumber" onKeyUp="jsBankDetails();"></asp:TextBox>
</div>
<div class="alt two-thirds columns" id="divChequeDate">
<asp:Label runat="server" ID="lblChequeDate" Text="Cheque Date"></asp:Label>
<asp:TextBox runat="server" ID="txtChequeDate" ReadOnly="true" onKeyUp="jsBankDetails();"></asp:TextBox>
<asp:CalendarExtender ID="calChequeDate" runat="server" TargetControlID="txtChequeDate"></asp:CalendarExtender>
</div>
<div class="alt two-thirds columns" id="div1">
<asp:Label runat="server" ID="lblCAmount" Text="Cheque Amount"></asp:Label>
<asp:TextBox runat="server" ID="txtCAmount" onKeyUp="jsBankDetails();"></asp:TextBox>
</div>
</fieldset>
</section>
<section id="secAnnualFee" runat="server">
<fieldset>
<div style="margin-top: 27px">
</div>
</fieldset>
</section>
<section>
<fieldset>
<asp:Panel ID="pnlFee" runat="server">
<table style="height: 500px; width: 350px;">
<tr>
<th colspan="3" style="font-size: x-large">
<center>
<table>
<tr>
<th >Fee Receipt
</th>
</tr>
</table>
</center>
</th>
</tr>
<tr>
<td>
<table style="width: 100%">
<tr>
<td></td>
<td style="float: left;">Date:<asp:Label runat="server" ID="lbljsDate"></asp:Label></td>
</tr>
<tr>
<td colspan="2">RollNo. & Name:
<asp:Label runat="server" ID="lbljsName"></asp:Label></td>
</tr>
<tr>
<td>Standard:
<asp:Label runat="server" ID="lbljsStandard"></asp:Label></td>
<td>Division:
<asp:Label runat="server" ID="lbljsDivision"></asp:Label></td>
</tr>
<tr>
<td rowspan="2" colspan="2">Months:<asp:Label runat="server" ID="lbljsMonths"></asp:Label></td>
</tr>
</table>
</td>
</tr>
<tr>
<th colspan="3">
<%--FeeDetails--%>
<asp:GridView runat="server" ID="gvAnnual" CssClass="gvmydatagrid" PagerStyle-CssClass="gvpager" HeaderStyle-CssClass="gvheader" RowStyle-CssClass="gvrows" AutoGenerateColumns="False" DataKeyNames="FeeHeadId" ShowHeaderWhenEmpty="true">
<Columns>
<asp:TemplateField HeaderText="Fee Name" ControlStyle-Width="200px">
<ItemTemplate>
<asp:HiddenField ID="hfFeeHeadId" runat="server" Value='<%#Eval("FeeHeadId") %>' />
<asp:Label ID="lblFeeHeadName" runat="server" Text='<%# Bind("FeeHeadName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount" ControlStyle-Width="100px">
<ItemTemplate>
<asp:HiddenField runat="server" ID="HiddenField2" Value='<%#Eval("FeeDefaultId") %>' />
<asp:HiddenField runat="server" ID="hfAmount" Value='<%#Eval("Amount") %>' />
<asp:TextBox ID="txtAmount" runat="server" Text='<%# Bind("Amount") %>' ReadOnly="true"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="gvheader"></HeaderStyle>
<PagerStyle CssClass="gvpager"></PagerStyle>
<RowStyle CssClass="gvrows"></RowStyle>
</asp:GridView>
<asp:GridView runat="server" ID="gvCustomFeePay" CssClass="gvmydatagrid" PagerStyle-CssClass="gvpager" HeaderStyle-CssClass="gvheader" RowStyle-CssClass="gvrows" EmptyDataText="No Record" AutoGenerateColumns="False" DataKeyNames="FeeHeadId" ShowHeader="false">
<Columns>
<asp:TemplateField HeaderText="Fee Name" ControlStyle-Width="200px">
<ItemTemplate>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("FeeHeadId") %>' />
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FeeHeadName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount" ControlStyle-Width="100px">
<ItemTemplate>
<asp:HiddenField runat="server" ID="HiddenField2" Value='<%#Eval("FeeDefaultId") %>' />
<asp:HiddenField runat="server" ID="hfAmount" Value='<%#Eval("Amount") %>' />
<asp:TextBox ID="txtAmount" runat="server" Text='<%#Eval("Amount") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="gvheader"></HeaderStyle>
<PagerStyle CssClass="gvpager"></PagerStyle>
<RowStyle CssClass="gvrows"></RowStyle>
</asp:GridView>
</th>
</tr>
<tr>
<th colspan="3">
<%--bank Details--%>
<asp:Label runat="server" ID="lbljsBankDetails"></asp:Label>
<asp:Label runat="server" ID="lbljsTotal" Text="Total" OnClick="javascript:Read();"></asp:Label>
</th>
</tr>
</table>
</asp:Panel>
</fieldset>
</section>
<section id="secButton" runat="server">
<fieldset>
<div class="alt two-thirds columns" style="margin-top: 12px">
<asp:Button ID="btnPayFee" runat="server" Text="Pay Fee" CssClass="btn btn-warning" OnClick="btnPayFee_Click" />
<asp:Button ID="btnReset" runat="server" Text="RESET" CssClass="btn btn-warning" />
<asp:Button ID="btnPrint" runat="server" Text="Print" CssClass="btn btn-warning" OnClientClick="javascript:return printPanel();"/>
<asp:Button ID="btnPrintSave" runat="server" Text="Print & Save" CssClass="btn btn-warning" />
<asp:Button runat="server" ID="Label2" Text="Total" OnClientClick="javascript:return Read();"></asp:Button>
</div>
</fieldset>
</section>
GetSelectedMonth()函数从我需要的月数获取月份名称,从gvVustomFeePay获取多个月份的月份名称,并从隐藏字段值更新选定月份的txtAmount。在ddlPaymentMode中选中支票时,在lbljsBankDetails中输入银行名称,支票号码,日期和金额的文本。
答案 0 :(得分:0)
如果您正在使用JavaScript:Gridview通常被绘制为一个表,因此您必须遍历表行和单元格才能找到您的文本框,除非您可以可靠地预测文本框将在何时获得的名称渲染。