html - Insert current date/time in HTTP POST -
i embedded developer , hosting form web page on embedded system. user fills out form sends message embedded system. can create whatever name , value fields want , sent embedded system. need stick in current date/time pc.
i've read through can find, feel answers missing things web developer take granted. example, know js , how create one. don't know how create field date/time filled out automatically sent embedded side.
there's button click send form defined as:
<input id="btnsubmit" type="submit" class="sm" value="send configuration message"></div>
the form defined as:
<form method="post" action="/config/index.htm" onsubmit="btn=document.getelementbyid('btnsubmit'); btn.value='(please wait)'; btn.disabled = true;" style="width: 1000px">
so seems need else onsubmit append time, possibly in new name/value field.
i've tried bunch of examples using js, php , other methods, bottom line when form received on embedded side there no date/time.
does have simple answer know-nothing me can implement?
the answer not nice-looking implementation might easy you. let's add hidden input field , fill in moment of submitting form.
- new input field
<input id="btnsubmit" type="submit" class="sm" value="send configuration message"> <input id='inputtime' name='time' type='hidden'> //the field hidden
- edit form onsubmit parameter
<form method="post" action="/config/index.htm" onsubmit=" document.getelementbyid('inputtime').value=new date().tojson().slice(0,16);btn=document.getelementbyid('btnsubmit'); btn.value='(please wait)'; btn.disabled = true;" style="width: 1000px">
once again, it's messy can copy-paste it. if want try more, try https://jsfiddle.net/ygtq8s8h/ (where added alert see being sent.)
Comments
Post a Comment