[英]Select multiple weeks via week input
I have a week input我有一个星期的输入
<input type="week" name="weeks" id="weeks">
I want to be able to select multiple weeks with this input.我希望能够使用此输入多周 select。 I tried the "multiple" parameter but it didn't work.我尝试了“多个”参数,但没有用。 Is there any way to do this?有什么办法吗?
I think you can try this idea:我想你可以试试这个想法:
In your JS:在你的 JS 中:
var weeks = [] //here store the weeks selected by the user;
function handler(e){
weeks.push(e.target.value)
}
In your HTML:在您的 HTML 中:
<input type="week" name="week" id="weeks" onchange="handler(event);">
<div class='weeks'>
<-- here you can display the selected weeks --!>
</div>
Show to the user only one input, and when he selects a week you save this week in the weeks array, and clear the week input to allow him to select another week.仅向用户显示一个输入,当他选择一周时,您将这一周保存在周数组中,并清除周输入以允许他在另一周使用 select。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.