如何自动填充两个字段中的日期选择器字段值
问题描述:
我在列表中有两个日期选择器字段,其中一个对表单是隐藏的。而我的客户希望隐藏的一个在另一个有价值的时候自动填充相同的值。
JS会被推荐。如何自动填充两个字段中的日期选择器字段值
这是我试过......
function autoPopulate() {
var first = document.getElementById('First Date'),
second = document.getElementById('Second Date');
first.onkeyup = function() {
second.value = first.value;
};
}
答
这里是一个小例子,我怎么插入的隐藏字段中的值,我怎么把它用在其他一些变量
var mydate = document.getElementById("demo").value = Date();
var hidden = document.getElementById('myField').value = mydate;
document.getElementById('printdate').innerHTML = hidden
<input type="text" style="width:500px" id="demo">
<input type="hidden" id="myField">
<p id="printdate"> is the hidden value that showing hidden date that we stored in hidden variable</p>
到目前为止您尝试过什么?请参阅[**我如何提出一个很好的问题**](https://stackoverflow.com/help/how-to-ask),如果适用,请使用您自己的代码来解决问题,[**如何创建一个最小化,完整和可验证的示例**](https://stackoverflow.com/help/mcve) – Nope
噢对不起,这是我试过的... function autoPopulate(){ var first = document。 getElementById('First Date'), second = document.getElementById('Second Date'); first.onkeyup = function(){ second.value = first.value; }; } – Maki