I'm very new in Adobe Livecycle, and I need to convert this to XFA. How could I do?
var f = this.getField("NN").value;
if(f == "0"){
event.value = Math.floor((this.getField("NN").value + 0.50) * 4);
}
if(f == "-1"){
event.value = Math.floor((this.getField("NN").value + 1.25) * 4);
}
if (n == ""){event.value = this.getField("Vazio").value;}
if(f >= "1"){event.value = Math.floor((this.getField("NN").value) * 4);
}
XFA not makes a sense to me....
Views
Replies
Total Likes
Hi,
The version of JavaScript that is used in LC Designer (XFA Forms) is different to that used in Acrobat (AcroForms), which is closer to Core JavaScript.
There are a lot of resources available online, which can help:
http://www.adobe.com/go/learn_lc_scriptingBasics
http://www.adobe.com/go/learn_lc_scriptingReference
http://www.adobe.com/go/learn_lc_formCalc
http://www.adobe.com/devnet/livecycle/articles/Adobe_XML_Form_Object_M odel_Refer ence.pdf
http://www.adobe.com/devnet/acrobat/pdfs/lc_migrating_acrobat_xmlform. pdf
And a very handy resource (and while it is for version 6 it is still very good because of the way it is laid out):http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf
The Help file in LC Designer can also help you with syntax and LC Designer itself comes with some great templates and examples.
Lastly, check out the Developer's Network on http://www.adobe.com/devnet/livecycle/
Also a book that doesn't deal with scripting at all but is very good on form layout is "Forms that Work" by Caroline Jarrett and Gerry Gaffney.
The Adobe "PDF Forms Bible" is okay, but mainly focuses on AcroForms.
Windjack Solutions have a subscription based service for solutions and scripts athttp://www.pdfscripting.com. It has a lot of AcroForm script that can be amended to suit LC Designer and a growing library of LC Designer solutions.
We have some solutions and blog posts on our website http://www.assuredynamics.com.
Now back to the script, in LC Designer:
var f = NN.rawValue;
if (f == 0) {
myEvent.rawValue = Math.floor(f + 0.50) * 4);
}
else if (f == -1) {
myEvent.rawValue = Math.floor(f + 1.25) * 4);
}else if (f == null || f == "") {
myEvent.rawValue = Vazio.rawValue;
}
else if (f >= 1) {myEvent.rawValue = Math.floor(f * 4);
}
Based on NN be a numeric field and the structure of the if statements, it looks to me that the first two if statements will always return zero.
Hope that helps,
Niall
The code did not work....
I wrote this code in Acrobat 8. If Acrobat 9 or above has the type "Calculated - User can be Override" like in LC in form, I will not to use LC to edit my form, if not, I will need to learn how do this in LC...
I tried do xfa.form.gurps1.NN.rawValue and still not work
Views
Replies
Total Likes
Can you share the form? If so upload it to a file sharing site like Acrobat.com and then post the published URL here.
It would make it much easier to see what is going on.
Niall
Views
Replies
Total Likes
This is the form that I'm editing using LC
http://www.4shared.com/document/XSKvSdwY/Cpia__2__de_Esqueleto_PP.html
The related filds are: NH_Relativo_1A ; NH_Relativo_1B, NH_1, NN_1, Tipo_1
And this is a test that I edited in Acrobat 8
http://www.4shared.com/document/mYcdXBHZ/Teste_Percia_3.html
Views
Replies
Total Likes
Hi,
I can't find your script anywhere. Which object contains the script?
I can find the NH_Relativo_1A ; NH_Relativo_1B, NH_1, NN_1, Tipo_1 fields, but not the field where you want to display the result of the calculation.
Please advise,
Niall
Views
Replies
Total Likes
They are here in JC
http://www.4shared.com/document/mYcdXBHZ/Teste_Percia_3.html
Views
Replies
Total Likes
I delete every codes from that fields
Views
Replies
Total Likes
Hi,
What you require, in what fields is not clear. I cannot follow the logic in the AcroForm and translate it to your structure in the XFA form.
I have taken the calculation in the "NN" object in the AcroForm and amended it in the "NN_1" field in the XFA form.
Hopefully the script will help you understand the XFA JavaScript syntax:
You can achieve what you want, but you will need to delve into the references and Help file.
If you need more help, you will need to be clearer in the calculation that you want, the object that will display the calculation and all of the objects that are used in the calculation.
Hope that helps,
Niall
Views
Replies
Total Likes
Here is the form: https://acrobat.com/#d=7O7S0s8cqnDLnq*EKCAoFQ
Views
Replies
Total Likes
I update my LC to ES and it works. I was using the LC 8
Views
Replies
Total Likes
Now the code works, but the calculate not!!! What's wrong???
This was edited with LC ES
http://www.4shared.com/document/0whehIbz/Cpia__2__de_Esqueleto_PP.html
This was edited with Acrobat *
http://www.4shared.com/document/kcJFbzOh/Teste_Percia.html
Translate
Validation test cost points and Skill Leves based on completion of the Level relative and type of expertise.
Type
in NH Relativo Atributo: ST, DX, IQ ou HT;
in NH Relativo Modificador: de -3 a +n ;
in Tipo: F, M , D e MD
(Obs its necessary complete the fields ST, DX, IQ and ST)
Views
Replies
Total Likes
It is possible to create a custom Calculate script for an AcroForm that allows the user to override the automatic calculation. The script just needs to look at the value of event.source and compare it to event.target. If they are equal, then don't go ahead with the calculation. Otherwise do.
Views
Replies
Total Likes
I update to ES version, I was using the LC 8 pro. Now the code works, something happen, but is NOT I want to happen!
This is the form http://www.4shared.com/document/iiPE5yxf/Cpia__2__de_Esqueleto_PP.html
I wrote in NH1 fild the follow script.
GURPS.Page1.NH1::calculate - (JavaScript, client)
var f = NH_Relativo_1A.rawValue;
if (f == "ST"){NH1.rawValue = ST.rawValue + NH_Relativo_1B.rawValue;
}
if (f == "DX"){NH1.rawValue = DX.rawValue + NH_Relativo_1B.rawValue;
}
if (f == "IQ"){NH1.rawValue = IQ.rawValue + NH_Relativo_1B.rawValue;
}
if (f == "HT"){NH1.rawValue = HT.rawValue + NH_Relativo_1B.rawValue;
}
if (x == ""){NH1.rawValue = Vazio.rawValue ;}
We are assume that ST field is "12" and NH_Relativo_1B is "-1" (minus 1), well if field NH_Relativo_1A is "ST" the follow calculate must be happen:
ST Field + NH_Relativo_1B
12-1
11
But when I inset "ST" in NH_Relativo_1A Field and -1 in NH_Relativo_1B the calculate returns 0 (zero)????, and when I input a positive number in NH_Relativo_1B, like "5", this result in 125 !!!!!, and NOT 17. Why?
The follow archive "Teste Pericia 1" have a similar code, but I wrote in Acroform, usingo Acrobat 8, and it works like I want.
This was edited with Acrobat *
http://www.4shared.com/document/kcJFbzOh/Teste_Percia.html
Translate
Validation test cost points and Skill Leves based on completion of the Level relative and type of expertise.
Type
in NH Relativo Atributo: ST, DX, IQ ou HT;
in NH Relativo Modificador: de -3 a +n ;
in Tipo: F, M , D e MD
(Obs its necessary complete the fields ST, DX, IQ and ST)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies