Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Modification of time script ot set value based on Radio Button Choice

Contributor ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

Hi all,

 

I am wondering if it is possible to add some script, that would allow reference to a Radio Button Group (called "Operatortimesingle1") that have Choices 1 & 2. I have a field ("Totaltime1") in which I have the following script (see below).

 

What I am thinking - is it possible to have reference to the "Operatortimesingle1" Radio Button Group in the script shown, that allows for the value of "0:00" to be true, if either of the Choices (1 or 2) are not selected, i.e. no Radio Button Choice is made (empty) - but vice versa - if either Radio Button Choice (1 or 2) is selected, the value as calculated by the script below, is then present?. 

 

Script in field "Totaltime1";

 

var aFields = new Array("Timesingle1", "Timesingle2", "Timesingle3", "Timesingle4", "Timesingle5", "Timesingle6", "Timesingle7", "Timesingle8", "Timesingle9", "Timesingle10");

var nSum = 0;
var sTime;
for(i = 0; i < aFields.length; i++) {
sTime = this.getField(aFields[i]).valueAsString;
if(sTime == "") sTime = "00:00";
nSum += HHMM2Min(sTime);
}
event.value = Min2HHMM(nSum);
function Min2HHMM(nMinutes) {
var s = util.printf("%,001.0f:%,202.0f", Math.floor(nMinutes / 60), nMinutes % 60);
return s;
}

TOPICS
PDF forms

Views

239

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , May 25, 2021 May 25, 2021
Sure. Change this line: event.value = Min2HHMM(nSum); To: event.value = this.getField("Operatortimesingle1").valueAsString=="Off" ? "0:00" : Min2HHMM(nSum);

Likes

Translate

Translate
Adobe Community Professional ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

Sure. Change this line:

event.value = Min2HHMM(nSum);

 

To:

event.value = this.getField("Operatortimesingle1").valueAsString=="Off" ? "0:00" : Min2HHMM(nSum);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

LATEST

Hi Try67,

 

Many thanks as always! spot on! 😉

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines