I have a text field named code. If M08 is entered in that field I want the numeric field named M08 to increase by 1. If M07 is entered I want numeric field named M07 to increase by 1. I have mutiple fields named code and each time any of the 50 different codes is entered I want the corresponding numeric field to increase by 1. Can I do this with and action or does it have to be done by a script?
Thank You
Solved! Go to Solution.
Views
Replies
Total Likes
You possibly will have to reference your numeric field more exactly.
As I don't know how your form is designed I cannot say if my script will match your needs.
To get the full reference to your numeric field do the following:
1. Place the text cursor into script editor where the reference should appear (| = cursor position):
if ($ eq "M08") then
| = + 1
endif
2. Now press and hold down crtl + shift and move the mouse cursor of the numeric field.
When a down arrow appears press the left mouse button.
3. The script editor then is populated with the full reference to the numeric field at the position you've placed the text cursor before.
This can look like this for example:
if ($ eq "M08") then
xfa.resolveNode("Formular1.#subform.NumericField1") = xfa.resolveNode("Formular1.#subform.NumericField1") + 1
endif
Views
Replies
Total Likes
Hi,
you will need two scripts in your code field.
in the exit:Event you put
if ($ eq "M08") then
NumericField1 = NumericField1 + 1
endif
in the enter:Event you should put, to avoid that the numeric fields value raises everytime you enter the field code.
$ = null
Both scripts are in FormCalc (not JavaScript)!
Views
Replies
Total Likes
Thanks for you response, I cant get it to work. I entered the exit.Event in the line for calculate for the text field (Code) and set it to Form calc.
I entered the enter.event in the line for calculate for the numeric field (NumericField1) and set it to Form Calc. I set the text field to user entered data and the numeric field to read only calculated. I just cut and pasted each line exactly as you wrote it. Will keep trying.
Thanks for your help.
Views
Replies
Total Likes
You possibly will have to reference your numeric field more exactly.
As I don't know how your form is designed I cannot say if my script will match your needs.
To get the full reference to your numeric field do the following:
1. Place the text cursor into script editor where the reference should appear (| = cursor position):
if ($ eq "M08") then
| = + 1
endif
2. Now press and hold down crtl + shift and move the mouse cursor of the numeric field.
When a down arrow appears press the left mouse button.
3. The script editor then is populated with the full reference to the numeric field at the position you've placed the text cursor before.
This can look like this for example:
if ($ eq "M08") then
xfa.resolveNode("Formular1.#subform.NumericField1") = xfa.resolveNode("Formular1.#subform.NumericField1") + 1
endif
Views
Replies
Total Likes
Thanks for all your help, I got it to work, but with one problem. If you type in the code then take out the code the number does not reduce. Is it possible to make it reduce because there will be mistakes made when entering the code.
Thank you for all your help again
Views
Replies
Total Likes
Views
Likes
Replies