Set Date/time field value on UI page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 12:56 AM
I have created a UI page and on UI page there are two date/time fields.
When any user selects in "From Date" or "To Date" field. Date should remain as it is but Time should round up to "00:00:00".
For example if user selects value in Date/time field 17-01-2017 19:13:04.
It should round up to 17-01-2017 00:00:00
HTML code:
<g:ui_date_time name="from_date" id="from_date" onchange="myFunction()" value="${jvar_from_date}"/>
Script that I have used to round the value and update the value.
<script>
function myFunction(){
var f_date = document.getElementById("from_date").value;
//alert(f_date);
round_date = f_date.split(" ")[0] + " " +"00:00:00";
alert("f_date " +round_date);
document.getElementById("from_date").innerHTML = round_date;
}
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 01:05 AM
try this:
function myFunction(){
var f_date = document.getElementById("from_date").value;
var round_date = f_date.split(" ")[0] + " " +"00:00:00";
//alert("f_date: " +round_date);
//document.getElementById("from_date").innerHTML = round_date;
$j('#from_date').val(round_date); //using jquery
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 01:23 AM
Hi Jack,
Thank you for response.
I have made it working by following script
<script>
function myFunction(){
var f_date = document.getElementById("from_date").value;
//alert(f_date);
round_date = f_date.split(" ")[0] + " " +"00:00:00";
document.getElementById("from_date").value = round_date;
}
</script>