开发者

Link for populating today's date in a form

开发者 https://www.devze.com 2023-02-04 13:02 出处:网络
I am using Java and JSF for creating a form and I need to click on a link which would say Today\'s date and clicking it will populate a form field with todays date.How should I code it out. I was plan

I am using Java and JSF for creating a form and I need to click on a link which would say Today's date and clicking it will populate a form field with todays date.How should I code it out. I was planning to use JavaScript! Any help a开发者_C百科ppreciated


<input id=Date name=Date value="">
<div style="cursor: pointer;" onclick="JavaScript: document.getElementById('Date').value = new Date();">Today's Date</div>


It sounds like you need a date picker that defaults to today's date. Try the jQuery Datepicker.


Not exactly an answer to your question, but why would you want to collect todays date from user interface. I mean, it's not like the user will have to choose between different todays, right?

Why not just use new Date() in the method called by your action in Java layer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号