自动时间元素js
automatic time element js
我刚刚为一个仓库做了一个from,但我觉得工人不应该每次都填写日期+时间,有没有办法用js自动填充一个隐藏的时间输入?我希望完整的日期+时间是这样的:DD/MM/YYYY H:MM这是我的代码:
<html>
<iframe src ="adminview.html" scrolling="no" height ="100"></iframe>
<!--this is the date and time script I am using to try to fill the input-->
<script>
var today = new Date();
var UTCstring = today.toUTCString();
</script>
<form action ="">
Name of employee:<br>
<input type ="text"></input>
Item no.:<br>
<input type ="text"></input>
Quantity of item:<br>
<input type ="text"></input>
<!--this is the input I am trying to fill with the above js-->
<input type ="hidden" value="UTCstring"></input>
</form>
</html>
给隐藏的输入一个id(例如:dateField(,然后将其添加到脚本中-
document.getElementById('dateField').value = UTCstring;
上面的行找到隐藏的日期字段,并在其中设置值。现在,您可以使用此值用默认值填充表单。(如果你想在客户端进行(
这是更新后的代码
<html>
<iframe src ="adminview.html" scrolling="no" height ="100"></iframe>
<!--this is the date and time script I am using to try to fill the input-->
<script>
var today = new Date();
var UTCstring = today.toUTCString();
document.getElementById('dateField').value = UTCstring; // or today.toUTCString();
</script>
<form action ="">
Name of employee:<br>
<input type ="text"></input>
Item no.:<br>
<input type ="text"></input>
Quantity of item:<br>
<input type ="text"></input>
<!--this is the input I am trying to fill with the above js-->
<input id="dateField" type ="hidden"></input>
</form>
</html>
相关文章:
- 制作一个chrome扩展,替换css和js元素
- Chosen.js:元素的宽度为0
- 拉斐尔:Chaining;.数据“;到一个拉斐尔.js元素
- 如何将onclick事件添加到joint.js元素中
- 手动呈现原型JS元素对象
- 从第三方原始javascript控制Angular JS元素
- 由于相机位置的原因,无法在场景中显示三个.js元素
- 将复杂的html/css/js元素添加到单个Wordpress页面中
- 向Fabric.js元素添加ID
- Angular Js元素未渲染
- 在属性名称中搜索带有冒号的 xpath 表达式会引发异常(节点.js元素树模块)
- 如何从 react.js 元素中删除特定的事件侦听器
- 不更新 .each 函数中的 D3.js 元素
- JavaScript 变量中的 PHP 数组 - JS 元素
- 检查变量是否为 SVG.js 元素实例
- 如何在基于 Backbone 的模板中添加数据.js元素
- 编写一个类似jQuery的JS元素选择器
- 创建 D3.js 元素 OnClick 事件的放大副本
- 如何覆盖 select2.js 元素之一的 z 索引
- Mouseover/out难题上的JS元素创建/删除