Effect: molding date - age = required test date!
event:
The event is triggered when the molded date text box is changed!
The event is triggered when the age text box is changed!
Code:
(Explanation: Molding date ID: tbcxrq Age ID: tblq Required test date ID: tbyqsyrq)
Copy the code code as follows:
<script type="text/javascript">
$(function() {
$("#<%=tbcxrq.ClientID %>").change(function() { CaclDate(); });
$("#<%=tblq.ClientID %>").change(function() { CaclDate(); });
//Calculate test time based on age
function CaclDate() {
if ($("#<%=tblq.ClientID %>").val() == "" || $("#<%=tbcxrq.ClientID %>").val() == "") {
$("#<%=tbyqsyrq.ClientID %>").val("");
}
else {
var MoldingDate = $("#<%=tbcxrq.ClientID %>").val();
MoldingDate = MoldingDate.replace("-", "/")
var d = new Date(MoldingDate);
var AgeDate = $("#<%=tblq.ClientID %>").val();
d.setDate(d.getDate() + parseInt(AgeDate));
var month = d.getMonth() + 1;
if (parseInt(month) < 10)
month = "0" + month;
var day = d.getDate();
if (parseInt(day) < 10)
day = "0" + day;
var date = (d.getFullYear()) + "-" + month + "-" + day;
$("#<%=tbyqsyrq.ClientID %>").val(date);
}
}
});
</script>