问题描述
好的Ev每个人我使用jquery为我的2个文本框1.txtStartDate 2.txtEndDate,我使用了第一个月份作为firsttextbox的默认日期和第二个文本框的当前日期以及第三个dropdownList我使用了Autopostback作为:
Good Ev everyone i am using jquery for my 2 textboxes 1.txtStartDate 2.txtEndDate , I have used first date of month as default date for firsttextbox and present date for second text box and on third dropdownList i have used Autopostback as :
<asp:DropDownList ID="ddlWorkType" CssClass="selectbox1 ddlWidth" ValidationGroup="tab1" runat="server" Enabled="true" AutoPostBack="true" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlWorkType_SelectedIndexChanged1">
每当我在第一个文本框中选择日期然后从下拉列表中选择值时,它会再次将第一个文本框的值重置为默认值
例如:textbox1 = 12-09-2017 textbox2 = 11-10-2017因为我在第三个文本框中选择它重置textbox1 = 01-10-的值2017
我的尝试:
whenever i select date in first textbox and then select value from dropdownlist it reset the vaue of first textbox again to default
example : textbox1=12-09-2017 textbox2 = 11-10-2017 as i select value in third text box it reset value of textbox1 = 01-10-2017
What I have tried:
$(function () {
$("#txtStartDate").datepicker({
dateFormat: 'yy-mm-dd',
showOn: 'button',
buttonImageOnly: true,
buttonImage: '/Image/calender.jpg',
buttonText: ""
}).bind("change", function () {
var minValue = $(this).val();
minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
})
var d = new Date();
var currMonth = d.getMonth();
var currYear = d.getFullYear();
var startDate = new Date(currYear, currMonth, 1);
$('#txtStartDate').datepicker('setDate', startDate);
$("#txtEndDate").datepicker({
dateFormat: 'yy-mm-dd',
showOn: 'button',
buttonImageOnly: true,
buttonImage: '/Image/calender.jpg',
buttonText: ""
}).bind("change", function () {
var minValue = $(this).val();
minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
})
$('#txtEndDate').datepicker('setDate', new Date());
});
推荐答案
这篇关于为什么文本框的值会从下拉列表中选择值时更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!