Hi,
I am new to Adobe script writing and need some help with a company wide form we use here at Marine Corops Communication-Electronics School. I am a MicroSoft Access programmer with over 20 years of experience. Any help with my problem will be greatly appreciated.
I am an electroincs instructor and part of my job is to evaluate other instructors. We have an Adobe Acrobat form that asks 49 questions. The dropdown list allows the values of N/A, 1,2,3,4, and 5 to be selected by the evaluator. The problem is the final average field. If the user selects N/A, the average is now wrong. I have tried different things but everytine I try to wrie a javascript program to do the calculations automatically, the field does not display anything.
I built a simple form that uses the same naming conventions as the final form. It has 3 dropdown fields and a final average field.
Here is all the code that I ahve been playing with;
int count;
int totalcount;
count = 0;
totalcount = 0;
totalcount = xfa.form.F.P1.DropDownList1.rawvalue + xfa.form.F.P1.DropDownList2.rawvalue + xfa.form.F.P1.DropDownList3.rawvalue;
if (xfa.form.F.P1.DropDownList1.rawvalue > 0) {
count = count +1;
}
if (xfa.form.F.P1.DropDownList2.rawvalue > 0) {
count = count+1;
}
if (xfa.form.F.P1.DropDownList3.rawvalue >0) {
count = count+1;
}
this.rawValue = totalcount / count;
I would have attached my file but I can't figure out how to do that.
Any help form anyone would be greatly appreciated.
Thank you ahead of time.
r/s
Martin Cox
Views
Replies
Total Likes
Hi Martin,
I have a couple of examples that might help: dropdowns and bar chart http://assure.ly/iitzNJ. An example of dropdowns with a N/A option http://assure.ly/uiKS6f.
Hope that helps,
Niall
Niall,
Thank you for the quick response. I can not get to your links using the computer at work. Your link is blocked, so I will try when I get home and let you know how things go.
Thank you again.
Martin
Views
Replies
Total Likes
Hi,
Just in case here are the plain URLs:
http://www.assuredynamics.com/index.php/portfolio/scoring-dropdowns/
http://www.assuredynamics.com/index.php/portfolio/scoring-three-options/
Niall
Views
Replies
Total Likes
Niall,
I was able to get to the new links you sent. Thank you.
I copied and modified your three options form as follows.
I deleted the options you had for each question and inputed N/A, 1,2,3,4,5 so their values are 0,1,2,3,4,5.
I changed your Marks scored to TotalScored and Marks available to Count.
I added a third number field called average and wrote the following script using your example. Again I get no output in the field.
this.rawValue = 0;
var oQuestion = question.all;
int iCount;
int iTotalCount;
for (var i=0; i<oQuestion.length; i++)
{
var vScore = xfa.resolveNode("question[" + i + "]").rawValue;
if (vScore > 0)
{
iTotalCount += Number(vScore);
iCount += 1;
}
// if only 1 question answered then display that number else
// calculate the average of the questions values
{
this.rawValue = iTotalCount/iCount;
}
else
{
this.rawValue = iTotalCount;
}
}
I don't get any errors. I have been trying to use the Adobe javascript debugger but can't seem to figure it out. The adobe help file Developing Acrobat applications Using javaScript tells be how to turn it on but mine version is completely different.
Anyway, again thank you for any help you can provide.
r/s
Martin Cox
Message was edited by: MartinCox2805ACo
We are using Adobe Acobat 8 Pro. and lifeCycle designer 8. Thank you again.
Views
Replies
Total Likes
Hi,
I think the problem is the way in which you have declared integers, instead of variables. I don't think this will work as set up in your script. Try working with the variables as a string and then access the .length property.
Niall
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies