How to remove/hide 'seconds' box on type 'duration' field?

jas101
Tera Expert

Hi guys, we use a duration type field for 'Downtime' on our change form. Is it possible to hide or remove the box that represents seconds on this duration field?

Many thanks.

1 ACCEPTED SOLUTION

Bhawana Upreti
Tera Guru

Hi,

 

You can do this by two ways:

1. DOM manipulation

2. Changing the system property - Go to System Properties > System > Time Format and knocked off the :ss  (seconds) and it will remove the SS part from your field but it will affect all fields of Time format within the system as this is Global change.

 

Thank you!

 

 

View solution in original post

5 REPLIES 5

No worries, I got it working by commenting out the minutes part of olegki's code (DOM manipulation).

So working onLoad client script to hide seconds from type duration field here:

function onLoad() {
var doc = g_form.getControl("DURATIONFIELDHERE").ownerDocument,
win = doc.defaultView,
table = g_form.getTableName(),
hideMinSecFields = function (field) {
function getElem (field, suffix, prefix) {
return doc.getElementById((prefix || "") + table + "." + field + (suffix || ""));
}
var controlHour = getElem(field, "dur_hour", "ni."),
controlMin = getElem(field, "dur_min", "ni."),
controlSec = getElem(field, "dur_sec", "ni."), cs;

if (controlMin != null && controlMin.style != null) {
controlMin.style.display = "none";
}
//if (controlSec != null && controlSec.style != null) {
if (win != null && win.getComputedStyle != null) {
cs = win.getComputedStyle(controlSec, null);
if (controlHour != null && controlHour.style != null && cs != null) {
controlHour.style.borderRightStyle = cs.getPropertyValue("border-right-style");
controlHour.style.borderRightWidth = cs.getPropertyValue("border-right-width");
controlHour.style.borderRightColor = cs.getPropertyValue("border-right-color");
controlHour.style.borderBottomRightRadius = cs.getPropertyValue("border-bottom-right-radius");
controlHour.style.borderTopRightRadius = cs.getPropertyValue("border-top-right-radius");
}
}
//controlSec.style.display = "none";
};
// }
hideMinSecFields("DURATIONFIELDHERE");
//hideMinSecFields("field2");
}