在下面的代码中,我试图根据用户选择的日期显示消息。如果日期大于04/26/2014,则warningAmount应为50000,如果日期小于04/26/2014,则warningAmount应为25000.用户选择的日期来自代码1,计算需要在如果阻止,则在else下的代码2。我试图做以下但它不起作用。请帮忙!
Code1:
<div class="input-section">
<p class="label">Shipping Date</p>
<input type="hidden" name="sShippingDate" id="sShippingDate" value="<fmt:formatDate pattern="MM/dd/yyyy" value="${claim.clMailingDate}" /> " />
<p class="info" id="shipDateValue">
<fmt:formatDate pattern="MM/dd/yyyy" value="${claim.clMailingDate}" />
代码2
_setWarningAmount = function _setWarningAmount(cod, registered) {
if (cod) {
_warningAmount = 1000;
} else if (registered && sShippingDate > 04/26/2014) {
_warningAmount = 50000;
} else if (registered && sShippingDate > 04/26/2014) {
_warningAmount = 25000;
} else {
_warningAmount = 5000;
}
_updateWarningAmount();
},
答案 0 :(得分:0)
我能够通过进行以下更改来解决它!
_setWarningAmount = function _setWarningAmount(cod, registered, shippingDate) {
var x = new Date(shippingDate);
var y = new Date('04/26/2014');
if (cod) {
_warningAmount = 1000;
} else if (registered && x > y) {
_warningAmount = 50000;
} else if (registered && x < y) {
_warningAmount = 25000;
} else {
_warningAmount = 5000;
}
_updateWarningAmount();
},