如何通过 HTML 发送数据

How to send data via HTML

您好,我需要通过 html 发送实际时间,例如:/time_12:12_1.1.2018 按钮或自动操作。我有代码,但我不知道如何连接它。

时间:

 <script>
    document.getElementById("demo").innerHTML = Date();
    </script>

发送数据:

<form action="/">PWM:
<input name="PWM" value="50" type="text"><input value="Submit" type="submit"></form>

有什么想法吗?

您想将日期作为表单数据或 uri 的一部分提交吗?

作为表单数据

<form action='/' method='POST'>
<input type='hidden' id='time' value='' />
<input type='submit' value='Submit' />
</form>

<script type='text/javascript'>
document.getElementById('time').value = Date();
</script>

作为 URI

<form id='timeForm' action='' method='POST'>
<input type='submit' value='Submit' />
</form>

<script type='text/javascript'>
document.getElementById('timeForm').action = '/'+Date();
</script>