RichFaces 4.2日历。如何通过JavaScript设置Calendar的InputField? [英] RichFaces 4.2 Calendar. How can I set the InputField of Calendar by JavaScript?
问题描述
我必须将客户端的日期字符串复制到日历输入字段renewal_date_input。以下JavaSript不起作用:
I have to copy a Date String at client side to the Calendar input field "renewal_date_input". The following JavaSript did not work:
document.getElementById('AddressDetails:renewal_date_input').value = renewalDateCombo.value.toString();
虽然有:
alert("written date is: " + document.getElementById('AddressDetails:renewal_date_input').value);
我们可以读出之前写的正确日期字符串。
但该字符串未出现在输入字段中。
启用手动输入:
We can read out the correct date string written previously. But the string does not appear in the input field. Manual Input is enabled:
enableManualInput="true"
也许JavaScript函数 setInputField:function(dateStr,event)
附带富面 calendar.js
可以提供帮助,但我该如何使用?
Perhaps the JavaScript Function setInputField: function(dateStr, event)
shipped with rich faces calendar.js
could help, but how do I use it?
推荐答案
使用 setValue()
日期组件上的函数,传递 Date
对象作为参数
Use the setValue()
function on the date component, passing a Date
object as argument
var theCalendar = document.getElementById('AddressDetails:renewal_date_input');
theCalendar.setValue(document.getElementById('AddressDetails:renewal_date_input').getValue()); //Here I assume renewal_date_input is also a calendar component
这篇关于RichFaces 4.2日历。如何通过JavaScript设置Calendar的InputField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!