Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Dependant drop down lists

Avatar

Level 1

I am building a form in livecycle and I need to use dependant drop downs where if I select a choice it will key 2 or 3 other drop downs with selected choices not the whole list. How do i do this easily ?  I am not familiar with javascript so I need help. I have attached the form in advance. The Region box when selected needs to key the company belongs to and the county to start with

Thanks,

John

5 Replies

Avatar

Level 6

Hi,

Let's say you have XML data file like this:

<empls>

<empl>
      <fg_code>0</fg_code>
      <empl_name>John</empl_name>
      <empl_code>854931</empl_code>
    </empl>
    <empl>
      <fg_code>0</fg_code>
      <empl_name>Paul</empl_name>
      <empl_code>855198</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Alex</empl_name>
      <empl_code>855744</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Agarkova Natalya</empl_name>
      <empl_code>854983</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Den</empl_name>
      <empl_code>854683</empl_code>
    </empl>
   </empls>

You can take data by fg_code with this scripts:

var fgCode = 1

var userCode= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_code")))

var userName= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_name")))

after that you will have two lists with names and codes.

Next you have to fill you drop down list with data, you can do it with this example:

var comboLen = userCode.length

for i=0 upto comboLen -1 step 1 do

$.addItem(userName.item(i)

, userCode.item(i))

endfor

All scripts written in FormCalc.

Example attached.

BR,

Paul Butenko

Avatar

Level 6

Hi,

Let's say you have XML data file like this:

<empls>

<empl>
      <fg_code>0</fg_code>
      <empl_name>John</empl_name>
      <empl_code>854931</empl_code>
    </empl>
    <empl>
      <fg_code>0</fg_code>
      <empl_name>Paul</empl_name>
      <empl_code>855198</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Alex</empl_name>
      <empl_code>855744</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Agarkova Natalya</empl_name>
      <empl_code>854983</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Den</empl_name>
      <empl_code>854683</empl_code>
    </empl>
   </empls>

You can take data by fg_code with this scripts:

var userCode= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_code")))

var userName= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_name")))

after that you will have two lists with names and codes.

Next you have to fill you drop down list with data, you can do it with this example:

All scripts written in FormCalc.

Example attached.

BR,

Paul Butenko

var comboLen = userCode.length

for i=0 upto comboLen -1 step 1 do

$.addItem(userName.item(i)

,

userCode.item(i))

endfor

var fgCode = 1

Avatar

Level 6

Hi,

Let's say you have XML data file like this:

<empls>

<empl>
      <fg_code>0</fg_code>
      <empl_name>John</empl_name>
      <empl_code>854931</empl_code>
    </empl>
    <empl>
      <fg_code>0</fg_code>
      <empl_name>Paul</empl_name>
      <empl_code>855198</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Alex</empl_name>
      <empl_code>855744</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Agarkova Natalya</empl_name>
      <empl_code>854983</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Den</empl_name>
      <empl_code>854683</empl_code>
    </empl>
   </empls>

You can take data by fg_code with this scripts:

var userCode= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_code")))

var userName= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_name")))

after that you will have two lists with names and codes.

Next you have to fill you drop down list with data, you can do it with this example:

All scripts written in FormCalc.

Example attached.

BR,

Paul Butenko

var comboLen = userCode.length

for i=0 upto comboLen -1 step 1 do

$.addItem(userName.item(i)

,

userCode.item(i))

endfor

var fgCode = 1

Avatar

Level 6

Hi,

Let's say you have XML data file like this:

<empls>

<empl>
      <fg_code>0</fg_code>
      <empl_name>John</empl_name>
      <empl_code>854931</empl_code>
    </empl>
    <empl>
      <fg_code>0</fg_code>
      <empl_name>Paul</empl_name>
      <empl_code>855198</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Alex</empl_name>
      <empl_code>855744</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Agarkova Natalya</empl_name>
      <empl_code>854983</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Den</empl_name>
      <empl_code>854683</empl_code>
    </empl>
   </empls>

You can take data by fg_code with this scripts:

var userCode= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_code")))

var userName= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_name")))

after that you will have two lists with names and codes.

Next you have to fill you drop down list with data, you can do it with this example:

All scripts written in FormCalc.

Example attached.

BR,

Paul Butenko

var comboLen = userCode.length

for i=0 upto comboLen -1 step 1 do

$.addItem(userName.item(i)

,

userCode.item(i))

endfor

var fgCode = 1

Avatar

Level 6

Hi,

Let's say you have XML data file like this:

<empls>

<empl>
      <fg_code>0</fg_code>
      <empl_name>John</empl_name>
      <empl_code>854931</empl_code>
    </empl>
    <empl>
      <fg_code>0</fg_code>
      <empl_name>Paul</empl_name>
      <empl_code>855198</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Alex</empl_name>
      <empl_code>855744</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Agarkova Natalya</empl_name>
      <empl_code>854983</empl_code>
    </empl>
    <empl>
      <fg_code>1</fg_code>
      <empl_name>Den</empl_name>
      <empl_code>854683</empl_code>
    </empl>
   </empls>

You can take data by fg_code with this scripts:

var userCode= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_code")))

var userName= Ref(xfa.resolveNodes(concat("$record.empls.empl.[fg_code==""",fgCode,"""].empl_name")))

after that you will have two lists with names and codes.

Next you have to fill you drop down list with data, you can do it with this example:

All scripts written in FormCalc.

Example attached. Rename extensions to correct.

BR,

Paul Butenko

var comboLen = userCode.length

for i=0 upto comboLen -1 step 1 do

$.addItem(userName.item(i)

,

userCode.item(i))

endfor

var fgCode = 1