Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

in repeating subforms can you script to stop the same value being selected more than once

Alistairscot
Level 2
Level 2

I have a LiveCycle Form with a repeating subform where the first field (text field 2 characters) requires the input of a code between 01 and 99. Can you  script so that you cannot enter the same code value more than once?

1 Accepted Solution
whyisthisme
Correct answer by
Level 7
Level 7

Here is some code in Formcalc which will work for what you want. Put it in the exit event for the textfield.

In this example the page is called myPage and the textField is called TextField1. Rename them as you need.

var indexCount = 0

var thisIndex = $.parent.index

while (indexCount < thisIndex) do

if (myPage[indexCount].TextField1 == myPage[thisIndex].TextField1) then

xfa.host.messageBox("You have already used that number")

$ = ""

endif

indexCount = indexCount + 1

endwhile

View solution in original post

6 Replies
yodadobe
Level 6
Level 6

You could loop through all instances checking their value.

Alistairscot
Level 2
Level 2

Are you aware of any sources where I can view the javascript code for such a loop? Got some books on Javascript but they all relate to web scripting - have not seen any that relate to LiveCycle/Acrobat.

whyisthisme
Correct answer by
Level 7
Level 7

Here is some code in Formcalc which will work for what you want. Put it in the exit event for the textfield.

In this example the page is called myPage and the textField is called TextField1. Rename them as you need.

var indexCount = 0

var thisIndex = $.parent.index

while (indexCount < thisIndex) do

if (myPage[indexCount].TextField1 == myPage[thisIndex].TextField1) then

xfa.host.messageBox("You have already used that number")

$ = ""

endif

indexCount = indexCount + 1

endwhile

View solution in original post

Alistairscot
Level 2
Level 2

Thank you for your help, just what I wanted it to do.

yodadobe
Level 6
Level 6

Documentation on JavaScript that is meant for use in a browser is still useful. The syntax is the same. The difference are in the objects that you call things on. Browser JavaScript has a default object of window. So alert("Test") is really window.alert("Test"). In Designer, you would need to use app.alert("Test"). If you needed to say modify a string, here would be a good place to get info: http://w3schools.com/js/default.asp

Alistairscot
Level 2
Level 2

Thanks again. I have very little experience with scripting or programming, so your comments are very helpful in giving me a focus on the subject. I have designed Forms for years in InDesign and saved as PDFs for writing up. See the advantages that Livecycle offers but am struggling with scripting.