-我有一个下拉列表,其中有一些选项可供用户选择。
- 选项为 1 天、1 周、2 周、1 个月和 6 个月
-现在,当我选择选项 1 day时,今天的日期应该增加一并显示下一个日期。
-如果我选择 1 周,则应显示一周后的日期。
-现在的问题是当我选择一个选项时,它有时会显示 date 大于 30/31。
-我使用以下javacript
功能:
function select_duration(ddlcupon) {
var skillsSelect = document.getElementById("ddlcupon");
var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;
if (selectedText == "1 Day") {
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate() + 1;
var year = currentTime.getFullYear();
var exdate = month + "/" + day + "/" + year;
document.getElementById('<%=txtEventDate.ClientID%>').value = exdate.toString();
}
if (selectedText == "1 Week") {
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate() + 7;
var year = currentTime.getFullYear();
var exdate = month + "/" + day + "/" + year;
document.getElementById('<%=txtEventDate.ClientID%>').value = exdate.toString();
}
if (selectedText == "2 Weeks") {
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate() + 14;
var year = currentTime.getFullYear();
var exdate = month + "/" + day + "/" + year;
document.getElementById('<%=txtEventDate.ClientID%>').value = exdate.toString();
}
if (selectedText == "1 Month") {
var currentTime = new Date();
var month = currentTime.getMonth() + 2;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var exdate = month + "/" + day + "/" + year;
document.getElementById('<%=txtEventDate.ClientID%>').value = exdate.toString();
}
if (selectedText == "6 Months") {
var currentTime = new Date();
var month = currentTime.getMonth() + 7;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var exdate = month + "/" + day + "/" + year;
document.getElementById('<%=txtEventDate.ClientID%>').value = exdate.toString();
}
-有人可以帮我找个合适的约会吗?