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

I want a javascript for adding minutes (:00 format) and the should be in total (:00000 format)

Engaged ,
Jul 19, 2016 Jul 19, 2016

I am making a pdf form in which user has to enter  the time in minutes (:00 format ex - 00:20 means 20 minutes)  and after they have entered all the fields it has to be added up in total field . the form is something like this

  

00:20     this mean 20 minutes

00:10     this means 10 minutes

00:05     this means 5 minutes

00:02     this means 2 minutes

00:50     this means 50 mintes

00:59      this means 59 ,minutes

00:146     the total should be 146 minutes and should in the format :00000  i.e total field should show 00:146 meaning 146 minutes and if total comes 10000 minutes it should as 00:10000

Please if anyone can help me to get this via pdf javascripting.

thanks in advance.

TOPICS
Acrobat SDK and JavaScript , Windows
1.2K
Translate
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 , Jul 20, 2016 Jul 20, 2016

You can use this code as the custom Format script:

if (event.value!="") event.value = "00:"+event.value;

Translate
Community Expert ,
Jul 20, 2016 Jul 20, 2016

What's the point of the "00:" part, then? If you just want to have minutes then you should just enter it as a pure number.

If you use the "00:00" format then the left part should be used for hours and the right part for minutes. So 146 minutes should be entered (or at least displayed) as: "02:26", not as "00:146"...

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

Sir,

But client want to display it as minutes  00:146  (146 minutes)  in the total column not in hours and minutes.

I want that only that one should enter a pure number but it should display in  00:00 format ( if 15 is entered it should show display as 00:15 meaning it is 15 minutes) and then all should add in the total field display  as  00:146.

Plz give me javascript for the above problem.

Translate
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
Community Expert ,
Jul 20, 2016 Jul 20, 2016

I would just use a custom Format script to add the "00:" part, then.

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

wat is javascript for that.. bcoz i a novice in these things.

Translate
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
Community Expert ,
Jul 20, 2016 Jul 20, 2016

You can use this code as the custom Format script:

if (event.value!="") event.value = "00:"+event.value;

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

Thank you for the help

i am stuck in one more problem.. if you could help me...

I have 28 fields in which numbers would be entered   and in the 29th field the maximum among the 28 numbers should be shown.

plz help me with the exact javascript.....

Thanking you

Translate
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
Community Expert ,
Jul 20, 2016 Jul 20, 2016

For that you can use the Math.max() method. See: JavaScript max() Method

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

but how to use them in the numbers are entered in the field as they are variables, and while calculating the greatest number it should leave the empty fields.

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

I want javascript  to be used in pdf form as Math.max() method is not working ...

plz provide me with the full pdf javascript to find the greatest number among the given numbers excluding the empty fields.

Thanking you

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

Sir,

Your Math.max() method didnot worked , i am asking for pdf form javascripting, well i got something for pdf forms but this is not working.... since you are an expert,  could you plz help me with the following script and edit the below script so that this works. My purpose is to find the greatest number among the 28 numbers populated by user my text field is name as  DP.1, DP.2 ........ DP.28

// custom calculation script for "Min"

var minValid = false;

var min = 0;

for (var i=0; i>=4; i++)

{

var val = parseInt(this.getField("DP." + i).value);

if (!isNaN(val)) // we have a valid number

{ if (minValid == true)

{ // this is the first valid value

min = val;

minValid = false;

}

else

{

min = Math.min(min, val);

}

}

}

if (minValid)

event.value = min;

else

event.value = "";

Translate
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
Community Expert ,
Jul 20, 2016 Jul 20, 2016

It will work if used correctly. If you want me to write the code for you contact me privately and we can discuss it further.

Translate
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 ,
Jul 20, 2016 Jul 20, 2016

how to contact you..... i don't have your contact details

Translate
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
Community Expert ,
Jul 20, 2016 Jul 20, 2016

hover your mouse over the user name

you may then click the Message option in the popup window to send a private email

DO NOT ASK FOR A SKYPE ADDRESS OR YOU WILL BE MARKED AS A SPAMMER

Translate
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 ,
Jul 20, 2016 Jul 20, 2016
LATEST

sorry sir, i am new to this .. thatswhy i didnot knew about the policy of the forum... i will take care of it in future

Translate
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