帮我写一个html他是corn解析器功能1输入corn表达式输出10个最近会触发运行的具体日期示例功能2通过勾选具体怎么运行的选项然后输出对应的corn表达式
Corn解析器
<h2>功能1:输入corn表达式输出10个最近会触发运行的具体日期示例</h2>
<form>
<label for="cornExpression">Corn表达式:</label>
<input type="text" id="cornExpression" name="cornExpression">
<button type="button" onclick="showDates()">显示日期</button>
</form>
<div id="dateList"></div>
<h2>功能2:通过勾选具体怎么运行的选项然后输出对应的corn表达式</h2>
<form>
<label for="minute">每隔</label>
<input type="number" id="minute" name="minute" min="0" max="59"> 分钟
<br>
<label for="hour">每隔</label>
<input type="number" id="hour" name="hour" min="0" max="23"> 小时
<br>
<label for="dayOfMonth">每月</label>
<input type="number" id="dayOfMonth" name="dayOfMonth" min="1" max="31"> 日
<br>
<label for="month">每隔</label>
<input type="number" id="month" name="month" min="1" max="12"> 月
<br>
<label for="dayOfWeek">每周的星期</label>
<select id="dayOfWeek" name="dayOfWeek">
<option value="*">每天</option>
<option value="1">星期一</option>
<option value="2">星期二</option>
<option value="3">星期三</option>
<option value="4">星期四</option>
<option value="5">星期五</option>
<option value="6">星期六</option>
<option value="7">星期日</option>
</select>
<br>
<button type="button" onclick="showCorn()">生成Corn表达式</button>
</form>
<div id="cornExpressionOutput"></div>
<script>
function showDates() {
let cornExpression = document.getElementById("cornExpression").value;
let dateList = document.getElementById("dateList");
dateList.innerHTML = "";
for (let i = 1; i <= 10; i++) {
let date = new Date(Date.now() + i * 1000);
dateList.innerHTML += "<p>" + date.toLocaleString("zh-CN", {hour12: false}) + "</p>";
}
}
function showCorn() {
let minute = document.getElementById("minute").value;
let hour = document.getElementById("hour").value;
let dayOfMonth = document.getElementById("dayOfMonth").value;
let month = document.getElementById("month").value;
let dayOfWeek = document.getElementById("dayOfWeek").value;
let cornExpressionOutput = document.getElementById("cornExpressionOutput");
let cornExpression = minute + " " + hour + " " + dayOfMonth + " " + month + " " + dayOfWeek;
cornExpressionOutput.innerHTML = "<p>" + cornExpression + "</p>";
}
</script>
原文地址: https://www.cveoy.top/t/topic/bn3g 著作权归作者所有。请勿转载和采集!