• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Engaged ,
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

522

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

Community Expert , 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);

Votes

Translate

Translate
Community Expert ,
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);

Votes

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
Engaged ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

LATEST

Hi Try67,

 

Many thanks as always! spot on! 😉

Votes

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