I have an MVC application with a number of forms. When the form is submitted it passed the users gps coordinates to the server. I also want to pass the clients current datetime.
Does anyone have any ideas as to the best way to do this?
The forms are standard html forms and use a basic submit.
My form would look like the one below. So how would I best attach the javascript datetime value to the submit call?
@using (Ajax.BeginForm("CheckIn", "Home", "Nothing", new AjaxOptions { }))
{
<fieldset>
<p>Move your Tile here to let those around you see it...</p>
<input type="hidden" name="lat" id="hckLat" value="" />
<input type="hidden" name="lon" id="hckLon" value="" />
<input type="hidden" name="date" id="hckDate" value="" />
<input type="submit" value="Check In!" />
</fieldset>
}
You can use
JavaScriptand theDatefunction which is rendered on the clients machine.Then you could pass the variable d to the server when you submit the co-ordinates.
From your edit:
In your
Checkinmethod in theHome controller, you could specify:To set the value of
hckDate, you could do:On the submit button click:
This would then be sent to the server.