Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

dynamically change the caption to the radio button

Avatar

Level 4

hello you can change the caption for the radio button dynamically? within a loop?

I tried these 5 education but do not work:


    list.RadioButtonList.nomelist.resolveNode("caption.value.#text").value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    list.RadioButtonList.nomelist.selectedMember().caption.value.text.value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    ListOggetto.resolveNode("caption.value.#text").value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    ListOggetto.selectedMember().caption.value.text.value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    list.RadioButtonList.nomelist.caption.value.resolveNode("#text").value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

this code:

//file xml

var numero = xfa.record.modulo.list.nodes.length;

for(i=0; i<numero; i++){

    var ListOggetto = xfa.resolveNode("list.RadioButtonList.nomelist["+i+"]");

   

    list.RadioButtonList.nomelist.resolveNode("caption.value.#text").value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    list.RadioButtonList.nomelist.selectedMember().caption.value.text.value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    ListOggetto.resolveNode("caption.value.#text").value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    ListOggetto.selectedMember().caption.value.text.value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

    list.RadioButtonList.nomelist.caption.value.resolveNode("#text").value = xfa.record.modulo.list.nodes.item(i).nomelist.code.value;

}

8 Replies

Avatar

Employee

Try this:

form1.p1.Button1::click - (JavaScript, client)

var number = xfa.resolveNode("xfa.form.form1.p1.rbl").nodes.length; //figure out how many children the exclusion group has

for (i=0;i<number;i++) {
xfa.resolveNode("xfa.form.form1.p1.rbl.rb[" + i + "].caption.value.text").value = "new caption for RB " + (i+1); //assumes all children are named 'rb'
}

result should be :

New caption for RB 1

New Caption for RB 2

Avatar

Level 4

thanks for the reply, unfortunately it does not work.

I'm going to take values ​​in a xml file

trying your code I should be in error


TypeError: xfa.resolveNode("list.RadioButtonList.nomelist[" + i + "].caption.value.text") is null

7:XFA:modulo[0]:pagina[0]:Button1[1]:click

Senza-titolo-1.gif

Avatar

Employee

Please look at my sample:

https://acrobat.com/#d=8WKhVvc-uMnJdnNZj007oQ


It looks like the context is wrong in your script.

KJ

Avatar

Level 4

http://www.filedropper.com/forumrb2

attached file, the data I take them in an xml file that is inside the pdf

Avatar

Level 4

Another problem I have to put radiobuttons horizontally

Avatar

Employee

Your proble was in the script:

The below script works in the context of your form. I don't have access to your data xml file, so I changed "record" to "form", and used the form model instead.

 

modulo.pagina.Button1[0]::click - (JavaScript, client)

 

//list.RadioButtonList.nomelist.caption.value.text.value = xfa.record.modulo.list.nomelist.value;

 

modulo.pagina.Button1[0]::click - (JavaScript, client)

//list.RadioButtonList.nomelist.caption.value.text.value = xfa.record.modulo.list.nomelist.value;

var numero = xfa.form.modulo.pagina.list.RadioButtonList.nodes.length;

app.alert(numero);

//pippo = new Array;
for(i=0; i<numero; i++){
xfa.resolveNode("xfa.form.modulo.pagina.list.RadioButtonList.nomelist[" + i + "].caption.value.text").value = "New Caption" + (i+1);
}

Result=

New Caption 1

Avatar

Employee

By default, the exclusionGroup is set to layout top to bottom, (layout="tb").

You can modify the layout such that it becomes

 

<

exclGroup name="RadioButtonList" layout="lr-tb

">

This will make it layout horizontally.

However, I would wrap the exclusionGroup in a subform, and set the subform to be flowed and western Text (lr-tb). The radiobButtons will be laid out horizontally.

Avatar

Level 4

hello thanks for the reply, I solved the problem of objects positioned horizontally, good


unfortunately I could not solve the problem of the caption, I have to force access to data from the xml file