cancel
Showing results for 
Search instead for 
Did you mean: 

Programming the Button Caption

Former Member
0 Kudos

Hi,

Can i know how to change the Button Caption using script?

Thanks

Gopal

Accepted Solutions (1)

Accepted Solutions (1)

chintan_virani
Active Contributor
0 Kudos

Gopal,

This is possible using Formcalc. Let's say if you have a button field named "Button1" the use the following code to change its caption:-

Button1.caption.value.#text = "<Put Text you want here>"

Chintan

Former Member
0 Kudos

Hi Chintan,

Thanks for your relpy..but I need it in JavaScript ...

The code given is used to set the caption, is there any way to get the caption using script?

Thanks

Gopal

chintan_virani
Active Contributor
0 Kudos

Gopal,

You have changed your intial question. Anyways this is possible too. Try this code in JavaScript :-

xfa.host.messageBox(Button1.resolveNode("Button1.caption.value.#text").value)

Also one more thing how does it matter if you get the result in Formcalc or JavaScript as long as you get it

Chintan

Former Member
0 Kudos

Hi,

Thanks for the answer...

But both JS and Formcalc cant be used in same event right ?

Thanks

Gopal

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Thanks for You Answers

Thanks

Gopal

Former Member
0 Kudos

I need both in Javascript

chintan_virani
Active Contributor
0 Kudos

Gopal,

Yes you are correct we cannot have a mix of Formcalc & JS ;-).

Here is the code you need though.

// Set the Button Caption
Button1.resolveNode("Button1.caption.value.#text").value = "Chintan";

// Display the Button caption in an alert.
xfa.host.messageBox(Button1.resolveNode("Button1.caption.value.#text").value);

Chintan

Former Member
0 Kudos

Hello Chintan,

Thanks for your solution. it works.

But I would like to install this code in a loop. The following Scpript doesn't work. where does I make mistake ?

var fields = xfa.resolveNodes("data.positions.Tabelle[*].TEST ");

var fields1 = xfa.resolveNodes("data.positions.Tabelle[*].TEST1 ");

for (var i=0; i <= fields.length-1; i++) {

if (fields.item(i).rawValue == null)

{

fields.item(i).presence = "hidden";

}else {

fields.item(i).presence = "visible";

if (fields1.item(i).rawValue == null)

{

fields1.item(i).presence = "hidden";

fields.item(i).resolveNode("fields.item(i).caption.value.#text").value = "TEST";

}else { fields1.item(i).presence = "visible";

fields.item(i).resolveNode("fields.item(i).caption.value.#text").value = "TEST1";

}

}

}

Edited by: Heidi Heinzberger on Mar 10, 2011 4:58 PM

Edited by: Heidi Heinzberger on Mar 10, 2011 4:58 PM