我对javascript和JSP还是很陌生,很难把头放在什么被调用的地方以及何时何地。我将所有这些都写在一个JSP文件中。我现在的起始代码是:
<input type=text name="myTextField" >
<input type=button name="myTextButton" value="Select a date"
onclick="displayDatePicker(myTextField)">
<script type="text/javascript">
// ???
</script>
让我感到困惑的第一件事是displayDatePicker函数。我一生无法找到有关此功能的任何文档(是jquery吗?是javascript吗?它是bootstrap吗?我可以传入其他args吗?)。一种替代方法是声明一个自定义函数,然后让myTextButton的onclick调用该函数。我设法使它起作用,但是我不知道如何显示在选择日期时实际上具有回调的日期选择器。
这是我想要的功能:
这将警告在框中键入的值。但是您应该为此使用UI。为什么要重新发明轮子。时间是宝贵的。jQuery UI由于其跨浏览器兼容性而成为最受欢迎的工具。
<input type="date" id="date">
<button onclick="date()">Select a date</button>
<script>
function date() {
var dateVal = document.getElementById("date").value;
alert("Your typed in " + dateVal);
}
</script>
jQuery UI日期选择器
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句