I am currently completely stuck with the debugger error message 'Employee.empvalidity() is not a function', and I have checked everything I could think of. This makes my entire form not work, and if I "remove" this function, the debugger jumps straight to the next function and reports that it too is not a function. I'm therefore suspecting that if I find the error, it will be solved for "all" the functions.
The form has worked fine previously with the function(s) I mentioned above, but I worked on the form a month ago or so, and must have (unfortunately) made some kind of change that I of course don't remember now, that ruined everything :-p
Ok, so to give a few details:
I have a radiobutton list 'EmpType' containing two radiobuttons. I also have a drop-down list (ActionDDList) and some JavaScript code that runs on the change event of the dd-list. It begins like this:
var actionvalue = form1.Main_subform.Caption_subform.ActionDDList.xfa.event.change;
if (actionvalue == "Competence Entry" || actionvalue == "New Employee" || actionvalue == "Internal Changes" || actionvalue == "Relocation" || actionvalue == "Resignation") {
var empcheck = Employee.empvalidity();
var loccheck = Employee.locationvalidity();
etc.....
The empvalidity() and locationvalidity() functions are located in a script object called Employee, the code for empvalidity() is like this:
function empvalidity() {
var emp = form1.Main_subform.Caption_subform.EmpType.rawValue;
if (emp == "1" || emp == "2") {
return true;
}
else {
xfa.host.messageBox("Please choose type of employee from the radio button list");
return false;
}
}
It's a simple function that only checks to see if the user has made a choice in the radiobutton list. As I mentioned before, this has worked perfectly before, so I guess the error is not to be found in the syntax of the code stated above..(?) But I would very much appreciate some hints as to where I can look for errors, as I'm completely lost and the debugger does not give me much help.. :-p
Acrobat has the unfortunate characteristic of not reporting errors that occur in the execution of the XFA scripting objects. Give this code a good look over. If you can't spot the problem by eye then you'll need to force Acrobat to report the problem.
Go to the JavaScript preferences and turn the "When an exception is thrown" to "trace". This should make the exceptions more verbose. The place a couple of console.println() statments in the scripting object to get an idea of how far excution is getting. You can also place the whole scripting object in a try/catch block and report the exception with a console.println().
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script