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

DropDown List formatted with numbers

Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

I have a dropdown box with only the numbers 3 & 6 in it. It is formatted to show as $3.00 and $6.00. Because of this formatting, I cannot add a "space" for a blank. It says the input does not match the format for the field.

How can I add a Null or blank before the 3 or 6 in the fropdown list?

Thanks in advance,

Bob

TOPICS
How to , JavaScript , PDF forms

Views

2.4K

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 4 Correct answers

Community Expert , Mar 31, 2021 Mar 31, 2021

Change the Format setting to None. Enter "$3.00" and "$6.00" as the display values and "3" and "6" as the export values, and that way you could use it in a calculation.

Votes

Translate

Translate
Community Expert , Mar 31, 2021 Mar 31, 2021

You can do what try67 suggested, or you can add 0 instead of blank/NULL.

Also go to every dropdown field, options tab and check "Commit selected value immediately" or you will have delay in calculations.

Votes

Translate

Translate
Community Expert , Mar 31, 2021 Mar 31, 2021

Yes it would show 0.

If you wish to add export value you can do it like this:

Izrezak.PNG

Votes

Translate

Translate
Community Expert , Apr 01, 2021 Apr 01, 2021

Try this:

function String2Min(cFormat, cString){

var oDate = util.scand(cFormat, cString); // convert string to Date object;

return Math.floor(oDate.getTime() / (1000 * 60)); // return minutes for Date object;

}
if(this.getField("DT1S").valueAsString == "" || this.getField("DT1E").valueAsString == "")
event.value = "";
else
{
var cDT1S = this.getField("DT1S").value; // get start field value;

var cDT1E = this.getField("DT1E").value; // get end field value;
// covert date strings to minutes and comput differ

...

Votes

Translate

Translate
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Change the Format setting to None. Enter "$3.00" and "$6.00" as the display values and "3" and "6" as the export values, and that way you could use it in a calculation.

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

How do I set the export value to "3" and "6"? Also then I asume I can add in a "Space" for the blank?

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
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

You can do what try67 suggested, or you can add 0 instead of blank/NULL.

Also go to every dropdown field, options tab and check "Commit selected value immediately" or you will have delay in calculations.

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Thanks for the suggestion. Would the 0 still show in the field? the idea is to not have all os or 3s in all 18 rows until selected by the user.

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
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Yes it would show 0.

If you wish to add export value you can do it like this:

Izrezak.PNG

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

I am so embarrassed. I looked everywhere for the Export Value and it was right under my nose.

Thank you so much for your help?

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
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

You can use a space as the display value and 0 as the export value, and then it wouldn't show up when selected.

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

I'd like to share the actual file if possible. I changed the "Rate" format to None and entered the options $ 3.00 and $ 6.00 with export values of 3 and 6, then also a space. Now there is a delay in the calcs.

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
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

It's because you use code in Total fields to color text to white I assume to hide zero so you get delay, try using this code instead:

if(this.getField("Rate1").valueAsString == " ")
event.value = "";
else
event.value = this.getField("Rate1").value * this.getField("Hours1").value;

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

That makes sense. However I entered that code in Total1 and it still won't update. I have to run now but will have to look at it again to see if I missed something.Screen Shot 2021-03-31 at 1.47.13 PM.png

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
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Your text color is probably left to white so you can't see it, try changing text color to black in field properties under appearance tab.

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

You are amazing! That works perfectly now. So now I'm down to 1 more item on my wishlist for this form. Hopefully you have an easy answer for me...:-)

 

I have two Date/Time fields, DT1S and DT1E. The "Hours" Field calculates the number of hours to one decimal place between the Start and End Date/Time Fields. Here is the code:

 

function String2Min(cFormat, cString){

var oDate = util.scand(cFormat, cString); // convert string to Date object;

return Math.floor(oDate.getTime() / (1000 * 60)); // return minutes for Date object;

}

var cDT1S = this.getField("DT1S").value; // get start field value;

var cDT1E = this.getField("DT1E").value; // get end field value;
// covert date strings to minutes and comput difference;

var nDiff = String2Min("m/d/yy HH:MM", cDT1E) - String2Min("m/d/yy HH:MM", cDT1S);

// format result as hours and set field value;

event.value = Number(util.printf("%,104.1f", (nDiff / 60)));

 

I would like have the formula NOT calculate until BOTH Time/Date fields are entered. If either or both are blank, then the calculation should not happen.

I saw a one line script not too long ago that checked the ".length" of one or more fields but I can't find it again. Was thinking that would be the way to go. It was an "IF/ELSE" statement.

 

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
Community Expert ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

Try this:

function String2Min(cFormat, cString){

var oDate = util.scand(cFormat, cString); // convert string to Date object;

return Math.floor(oDate.getTime() / (1000 * 60)); // return minutes for Date object;

}
if(this.getField("DT1S").valueAsString == "" || this.getField("DT1E").valueAsString == "")
event.value = "";
else
{
var cDT1S = this.getField("DT1S").value; // get start field value;

var cDT1E = this.getField("DT1E").value; // get end field value;
// covert date strings to minutes and comput difference;

var nDiff = String2Min("m/d/yy HH:MM", cDT1E) - String2Min("m/d/yy HH:MM", cDT1S);

// format result as hours and set field value;

event.value = Number(util.printf("%,104.1f", (nDiff / 60)));}

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
Explorer ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

Viola!!! You have made my day and my Form!!! It all works perfectly and it does everything I set out to accomplish. I could not have done this without all the community help and yours especially.

Everyone contibutes differently and sometimes those with the most experience don't have as much patience with us newbies. You answered at my level and made it easy to understand.

I can't thank you enought!!! Can't wait to try another project!!!

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
Explorer ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

Well...... 😞   Just when everything was working perfectly (on my Mac)...

1) Testing it on a Windows laptop, the formulas don't work and "NaN" appears in the "Hours" Field

2) Testing it on the iPad, none of the formulas work. THe Date and Time fields actual populate with a Rolling Calendar selection which is really cool but the formulas aren't woking.

Any ideas???

 

Thanks again in advance....

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
Community Expert ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

On iPad you can try 'PDF Expert' app by Readdle.

On windows it should work with acrobat.

Since you had a lot of calculations I made you loop code to go through fields now you have only two codes in the file, test it and see if it works.

https://drive.google.com/uc?export=download&id=1gju6F2rEnMpoX7pf3TXmd3T121PJUhun 

 

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
Explorer ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

Wow. All that work and you have it all in the Total Sum. Amazing. Good learning experience.

Guess will have to use something like PDF Expert on iPad. I'll have a co worker try it on his Windows Laptop using acrobat.

Thank you again and I'll try to kgive an update if and when we get this going on all iPads.

We have over 200 pilots that could be using this.

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
Community Expert ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

The OS isn't important. It's all about the PDF viewer. What viewers did you use on the various systems?

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Explorer ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

LATEST

On my Mac I used Acrobat XI to build and view the file.

On the iPad we of course tried Acrobat Reader to no avail. I did download PDF Expert for the iPad (1 week free trial then $49.99/yr.) and it worked great but for over 200 pilots at $49.99, that's not a real good option.

Not sure what my co worker used on his Windows laptop.

 

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