Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all 12130 articles
Browse latest View live

How do I count/add fields with numbers and fields with letters?

$
0
0

This is an attendance calendar I'm making for my work.

Cells in CLIENT A column will be marked with either a number ( >0, indicating how many hours attended) or a letter (A = absent, H = Holiday).

I need 2 formulas/scripts I suppose:

 

1) I would like cell DP1 to represent how many cells in the CLIENT A column are marked only with a number >0 -indicating how many days were attended, not how many total hours there are.

 

2) I would like cell DA1 to represent how many cells in the CLIENT A column are marked only with the letter A -indicating how many days were not attended.

at mil draft_Page_1.jpg


pdf http request

$
0
0

hello

 

I work on Acrobat Pro

 

My goal is to send arequest HTTPthrough my PDF file

 

I took a classic example:

 

I put javascript code in Programmes/Acrobat/......../javascript/


ajax = function(cURL) {

    var params =

    {

            cVerb: "GET",

            cURL: cURL,

            oHandler:

            {

                    response: function(msg, uri, e,h){

                            var stream = msg;

                            var string = "";

                            string = SOAP.stringFromStream( stream );

                            app.alert( string );

                    }

            }

    };

 

    Net.HTTP.request(params);

}

 

app.addMenuItem({ cName: "Go PHP", cParent: "File",

    cExec: 'ajax( "http://localhost/myPage.php");',

    cEnable: "event.rc = (event.target != null);",

    nPos: 0

});

 

but when I go to "File/Go PHP" Acrobat says that it isan internal error


what is problem?

 

Thanks

Custom JavaScript to omit NA selection.

$
0
0

I have a form that uses 5 sections of combo boxes. In section has 4 sets of combo boxes and you have the option to choose 0,1,2,3, and NA. Beside each of those combo boxes is a score which reflects what you have chosen in each combo box. At the end of each section is a score which gives you an average of the above 4 choices.

 

I need to write in custom JavaScript that lets you get the average if the user selects NA. As NA does not count in the score. If the user selects NA the score would now be out of 3 not 4 and so on depending on hos many times the user selects NA.

 

I will also need custom JavaScript in the final section that gives me the average of all final scores and omits the NA as well. Could someone please help me with this custom JavaScript as I have no knowledge of JavaScript only that I need it.

"Save a copy" does not run the JavaScript defined for AA WS/DS

$
0
0

I'm displaying the pdf in browser (IE) and need to audit the user saving the file (e.g. from the floating toolbar's "Save a copy"). However, the script inserted to run on Additional Action Did Save/Will Save is not invoked (the script and the structure of the document are ok because I'm doing the exact same thing for Did Print and works just fine).

 

So it looks like "Save a copy" is not "Save" .

 

Any idea on how to work around this?

 

Thanks,

Radu

Custom JavaScript Help

$
0
0

I have 5 combo boxes with choices of Y, N and NA. When yes is selected the score will equal 3, when no is selected the score will equal 0, when NA is selected the score will show no score. I have a text box that will then show the final score from the 5 combo boxes, out of a possible 15. I have one last text field that will show a pass or fail. A pass would be 15 anything less than a 15 is a fail. I have custom JavaScript stating the following:

 

var aFields = new Array("6 Combo Box 1", "6 Combo Box 2", "6 Combo Box 3", "6 Combo Box 4", "6 Combo Box 5");

var aDefault = new Array();

for (var i = 0; i < aFields.length; i++){

     if (this.getField(aFields[i]).value == this.getField(aFields[i]).defaultValue){  //compares field value to default value which is empty

          aDefault.push(aFields[i]);  //this will create an array of fields not filled in

     }

}

 

var v = +this.getField("Model Call Score").value;

if (v>14) event.value = "Pass";

else event.value = "Fail";

 

 

//verify if aDefault contains at least one field

if (aDefault.length >0){

     event.target.display = display.hidden; 

//hide my value if a field is still empty

 

}

else{

     event.target.display = display.visible;

}

 

I understand that the last part of the code said to make the value hidden. I want a pass or a fail to show up only when all combo boxes are selected. I do not have knowledge of JavaScript. Could someone please help me correct my current code or come up with another suggestion. Attached is a link to my form. My above question is referring to the bottom section.

Saving - Network versus Local Drive

$
0
0

We created an inventory sheet using Acrobat Pro X that does some calculations. Once we fill it out we save it to capture the data and then create a flatten version to send to customers to avoid issues with some mobile customers not being able to read the pdf. We save a flatten version with a slightly different name to tell then apart. The original code worked when using a shared network drive. When we try to run the form on the physical drive and same directory Acrobat throws an error "Missing Save Function Please check for blank Shippers Name field". Is there is there a simple fix?

 

Simple Save

var text1Value = this.getField("Customer").value;

var newFileName = "1 " + text1Value + " Inventory.pdf";

 

 

if(typeof(mySaveAs) == "function") {

    var nLast = this.path.lastIndexOf("/");

    var cPath = this.path.slice(0,nLast);

    mySaveAs(this,cPath, this.newFileName);

}

else {

    app.alert("Missing Save Function\n" + "Please check for blank Customers Name field");

}

 

Save and Flatten

var text1Value = this.getField("Customer").value;

var newFileName = "1 " + text1Value + " InventoryF.pdf";

 

 

this.flattenPages({nStart:  0, nEnd: (this.numPages - 1), nNonPrint: 0});

 

 

if(typeof(mySaveAs) == "function") {

    var nLast = this.path.lastIndexOf("/");

    var cPath = this.path.slice(0,nLast);

    mySaveAs(this,cPath, this.newFileName);

}

else {

    app.alert("Missing Save Function\n" + "Please check for blank Customers Name field");

}

Newbee here :- How do I run a JavaScript on a field without selecting a trigger?

Checkbox change value in field and reveal hidden text

$
0
0

Hi

I need to change a value in a field when a checkbox is pressed

the default value could be 10$ in "formfield1"

But when the checbox is checked the value in "formfield1" should change to 8$

I also need a function to reval text in "textfield2" from hidden to visible text.

Is that even possible to combine in one checkbox?

I found some code  in the forum and modified it but it does not work as expected, it affects field it should not and it behaves a bit funny, below is the code to calculate.

Also i tried to change the value from Off to On, but that didnt reversed the procedure as i hoped.

Well Its a start, maybe someone can figure it out an give me some help on the way?

 

________________________________

// custom calculation for discount

var nDiscount = 2;

// sub total field name

var cSubTotal = "formfield1";

// non-Discount check box name

var cbNonDiscount = "CheckBox1";

// set default value for non-Discount

event.value = 10;

// see if purchase is with Discount or not non-Discount

if(this.getField(cbNonDiscount).value == "Off") {

event.value = this.getField(cSubTotal).value - nDiscount;

}

// end custom calculating


What action besides the mailto: one will work with a submit button to activate the required fields?

$
0
0

I have a submit button that uses the mailto: function to activate the required fields property on a pdf fillable form, but our users would prefer that the form not generate an email. Please let me know what I could replace the mailto: action with so the submit button will only activate the required fields proptery.

 

Thanks for the help!

 

Ken K. 

Calculating a due date in Adobe XI using Java script....

$
0
0

I have two fields in a form. One with today's date being calculated with the following:

 

var f=this.getField("Today");f.value=new Date();

 

The second field I am trying to add 7 days to, but I can't figure it out. What script would I need to add into the existing field which is populating date and add to the new field to populate this information. I've tried a lot of what I've found on the internet but nothing seems to work..

 

Also, please note, I am using the 'Document Javascripts" editor in Adobe XI Pro.

 

Any help is appreciated


Exporting FDF files using Acrobat Reader

$
0
0
I have developed some forms using Acrobat Pro v9 that have buttons to save the data as FDF files using the exportAsFDF function and another button that saves the file as a PDF file with the new data.

This has been done as we normally only save the FDF file to save space but need the PDF file with data if we are E-mailing it to a client.

Both buttons work fine when used in Acrobat v9 but when a Reader enabled file is used in Adobe Reader v9 only the PDF button works. The FDF button does nothing when it is clicked.

I assume that this is because the security settings on the exportAsFDF function prevent its use in Reader by default.

Is there any way of enabling this function via Acrobat and the form so that the a user having Adobe Reader only can save an FDF file after editing the data?

Acrobat 9 Batch Processing - Get PDF filenames from folder?

$
0
0

Hello,

 

Can anyone provide me with an example with how to use Batch Processing (when set to a specific folder/files) to get a list of filenames in that folder? I haven't been able to find any examples online. There doesn't seem to be any built in batch sequences that automatically do this so I assume it will need to be done with javascript?

 

Ultimately, I need to automate a process (I was hoping to create a batch sequence to accomplish this) that will allow me to prompt a user to pick a source folder of PDFs and then based on that selection, run a Javascript that I create which will merge all PDFs in that folder into a new PDF, apply some crop setttings to each page, and then prompt the user where to save the merged PDF?

 

Has anyone ever done anything like this? I would love to see an example of how this might be able to be achieved.

 

Many thanks in advance.

If/then checkbox script help in Adobe Acrobat Form...

$
0
0

If have an order form that has two different pricing fields (regular price per item & subscription price per item) for each line item and then a quantity and then a total field. Lastly, there is a checkbox on the form that indicate if they are signing up for a monthly subscription.

 

What I am trying to do is create a script that totals each line by the regular price multipled by the quantity or subscription price by quantity if the subscription check box is checked ("Yes"). So far, I've tried several scripts I found in the forum but no luck at all.

 

The check box is near the billing fields toward the bottom so all the line items appear first in the top section of the form. So, an individual would fill out each line and the calculations would just total each row (reg price * qty) as you go down the form...then when you check the subscription box all the line totals would change to reflect the subscription pricing for each row (which can be different). Just need help with one row and I can duplicate for each row.....

 

Here is what I have that does NOT work yet.....:

 

 

 (function () {


if (this.getField("sub").value==="Yes") {
     var b1 = this.getField("Price1b");     var c1 = this.getField("Qty1");     var d1 = this.getField("Price1");     event.value = b1.value * c1.value;
} else event.value = d1.value * c1.value;    }


)();

Lengthy Drop Down List Items

$
0
0

I am completely new to Acrobat and Javascripts.

 

Are there any scripts that can:

- Wrap text within a drop down list?

- Automatically wrap long drop down items into a text field below it?

 

Or, if there is an invisible multiline text field beneath the drop down list, is there a script that can:

- Make the text field visible and the drop down list invisible when the entry reaches the right margin,

- Automatically move the drop down item or custom text into the text field,

- Still allow the user to select a different item from the drop down list if necessary?

 

Please kindly include directions as to how and where the scripts should be applied if any of these are possible.

 

Thank you dearly in advance.

JavaScript Validation to Submit Form

$
0
0
Hi,

How do you validate all the fields in JavaScript when the user clicks the Submit button so that if any required fields are empty or any field validation fails, nothing (submission, JavaScript code, execute menu items, etc.) will be executed? I found something about execValidate() but it didnt work for me. It wouldnt do anything. I am using Adobe Acrobat Professional 8.0.

For instance, I have a field set up to accept numbers between 1111 and 9999. If the user enters 1 and tabs out of the field, he gets an error message and the value is deleted. The field is also set as a required field. But if the user clicks the Submit button, all JavaScript code will be executed, menu items too. The only thing that fails is "Submit a Form" only for the required field part. What can I include in the JavaScript code to check if all fields are valid, according to their corresponding rules, and if yes, continue to execute all the other actions. If not, cancel all and let user make the necessary changes.

Thank you for your help!

Lock form & email as PDF Javascript

$
0
0

Hi Guys,

 

I am using Adobe Acrobat X and creating a Forms natively. We do not use LiveCycle.

 

So I have created a form with several fields, buttons a date picker - some of which I have found online.

 

The forms that I will be creating will be placed on the Intranet of the Organisation that I work for.

 

So what I need is for our users to fill out the form online. Press the Submit button. When they press submit the form must lock all the contents. We do not want to contents edited when it reaches its destination. The submit button will also call up the default email program, populate the TO: field with a specified email address and the Subject field with specified text.

 

The form must arrive at its destination in PDF format.

 

Been stuck on this one for a while. I used some simple html with the submit button for a while and that mostly worked except the part about locking the form.

 

So if someone can java me up a solution i would greatly appreciate it.

 

I have tried a few of the solutions a few solutions from the lifecycle partof the forum but apparently the java is different!

 

Many thanks,

Nick

Adding a date stamp using Acrobat XI

$
0
0

Hi there

 

I want to add a date stamp to a voucher PDF, so that when it is downloaded and printed out, it displays today's (system) date.

 

I followed the tutorial at: http://tv.adobe.com/watch/acrobat-x-tips-tricks/quick-tip-how-to-add-a-date-stamp-to-a-for m/   ,double checked the javascript, and this seemed to work. But when I checked the following day, the date displayed was still set at yesterday's date. It had not moved forward. I tried saving as Reader Extended/Enable More Tools, but that didn't work either and I think it removed the JavaScript altogether.

 

In the original, I went to  Edit All JavaScripts and this is the code that was there:

 

//-------------------------------------------------------------

//-----------------Do not edit the XML tags--------------------

//-------------------------------------------------------------

 

//<Document-Actions>

//<ACRO_source>Document Will Print</ACRO_source>

//<ACRO_script>

/*********** belongs to: Document-Actions:Document Will Print ***********/

var f = this.getField("DatePrinted");

f.hidden = false;

f.value = "Printed on: " + util.printd("mmm dd, yyyy", new Date());

//</ACRO_script>

//</Document-Actions>

 

 

Can anyone please help?

open file using Javascript

$
0
0
I am trying to open a file using a javascript dropdown menu. I know acrobat allows users to open a single file using the standard features, but I have about 30 different files that need to be referenced. the general idea is currently;

window.open("C:\Documents and Settings\Desktop\" + event.value + ".pdf");

Besides the fact it doesn't work at all, I'm getting an error message "unterminated string literal". This is due to the \ right before the end of the directory string. but I cannot think of a way to finish the directory string without using this methoid. (i've also tried assigning the '\' to it's own variable but that is throwing the same error. if you have any idea, please let me know. I may have fixed this issue, i'm using \\ instead of \ after Desktop, but the file still will not open. I've also tried using app.launchURL to no avail. please help me with another open command, please.

Using Excel VBA to save PDF file as a text (plain) file?

$
0
0

I'm using 8.0 Acrobat Pro.

 

Third party apps are not an option (I'm restricted from installing anything on my office PC).

 

I could simply save each PDF manually, but given the number of files this would not be practical.

 

The text it will output does not have to be pretty by any means (and I'm aware it won't be).

 

As long as I can get the PDF files in a text file format, there would be no further obstacles for me - because I would then be able to get Excel to gather-import all the data and consolidate-clean-organize everything accordingly at that point.

 

What's in these PDF files are simply names, numbers, and email addresses (basic office text type data stuff simple).

 

I wish to save them all as text files, and then use Excel to suck all the data from those newly created text files and consolidate-organize them accordingly.

 

The VBA module I've seen referrenced around the web is the following beneath; however, I am having no luck with it.

 

 

 

I keep getting the error message:

ActiveX component can't create object or  return reference to this object (Error 429)

 

I am running Microsoft Office 2010 | Excel (and using Adobe Acrobat Pro 8.0).

 

Any help is extremely appreciated.

 

Here is the VB code in Excel I'm having trouble with:  What this is supposed to do is simply find the specified PDF file and save it as a Plain Txt File.

 

 

Sub Convert_PDF_To_Text_File()

'---------------------------------

Dim AcroXApp As Object

Dim AcroXAVDoc As Object

Dim AcroXPDDoc As Object

 

Set AcroXApp = CreateObject("AcroExch.App")

AcroXApp.Hide

 

Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")

AcroXAVDoc.Open strPDFPath, "Acrobat"

AcroXAVDoc.BringToFront

 

Set AcroXPDDoc = AcroXAVDoc.GetPDDoc

 

Dim jsObj As Object

Set jsObj = AcroXPDDoc.GetJSObject

 

jsObj.SaveAs strOutputFile, "com.adobe.acrobat.plain-text"

 

AcroXAVDoc.Close False

AcroXApp.Exit

'---------------------------------

End Sub

Defaulting to current date for a text field

$
0
0
Acrobat Version 8.1.2
I would like to have my Adobe form take the current date default for a text field. Any idea how this can be done? I tried following on the Field Properties Calculate Tab "Custom Calculation script". Field name is TodayDate.

var TodayDate = this.getField("Today");
TodayDate.value = util.printd("mm/dd/yyyy", new date());

Anybody knows what am I doing wrong?
Viewing all 12130 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>