Anyone know how to test and see if a checkbox is checked on a PDF form with Javascript? I need an if/else statement for producing a result if the box is checked or not.
TIABBQ!!
As far as I know, this is not done with javascript? Is it not all internal to the PDF?
If you are sending the PDF by mail and expecting a response via mail, I've coded a little desktop flash app that converts the generated XML to a CSV... if you are keen to get the source let me know.
well, you can have form elements execute javascript internally in the PDF based on user actions - printing, saving, etc.
These are local use PDFs only. Basically I've got a form that grabs the current date from the system and fills in a text field when the user prints. I wanted to have the date be optional via the checkbox. Box is checked, print the date...box is unchecked, don't print the date.
I did some automated-PDF scripts like that a few years back, so this maybe a little sketchy but try something like:
var doPrintDate = this.getField('printDate').value; if (doPrintDate != "Off") { //populate date field code here }
i figured it out...there were a few errors in my logic and syntax. This takes a value from a select box and populates the "NetWeight" fields as well as tests a checkbox for it's value and populates a set of date fields accordingly. There are multiple fields on the same page that need the same data, hence the for loop.
var i=0; var printMe = ""; var roastedDate = "Roasted on: " + util.printd("mm.dd.yy", new Date()); var noDate = " "; function checkCheckbox(){ if (this.getField("PrintRoastDate").isBoxChecked(0) == true) { printMe = roastedDate; } else { printMe = noDate; } return printMe; } checkCheckbox();
for (i = 1; i <= 3; i++) { this.getField("PrintDate"+i).value = printMe; this.getField("NetWeight"+i).value = this.getField("Weight").value; }