Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

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

Avatar

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

Avatar

Correct answer by
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

Avatar

Former Community Member

You could loop through all instances checking their value.

Avatar

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.

Avatar

Correct answer by
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

Avatar

Level 2

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

Avatar

Former Community Member

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

Avatar

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.