如何在两个字段中自动填充日期选择器字段值

时间:2017-08-31 14:07:14

标签: javascript sharepoint

我在列表中有两个日期选择器字段,一个在表单中隐藏。并且我的客户希望隐藏的一个在另一个有价值时自动填充相同的值 JS会被推荐。

这就是我试过的......

function autoPopulate() {
  var first = document.getElementById('First Date'),
    second = document.getElementById('Second Date');
  first.onkeyup = function() {
    second.value = first.value;
  };
}

1 个答案:

答案 0 :(得分:0)

这是一个小例子,我如何在隐藏字段中插入值以及如何在其他变量中使用它

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>

相关问题