Expand my Community achievements bar.

Javascript help

Avatar

Former Community Member
I'm new to Java and was trying to display two hidden checkboxes in a dynamic form upon clicking on a third checkbox. I've tried the script bellow but it doesn't work. Any help is appreciated. Thanks



form1.#subform[0].CheckBox1::mouseUp - (JavaScript, client)

var inp1 = this.getField("CheckBox2")

var inp2 = this.getField("CheckBox3")

if (event.target.value == "Yes")

{

inp1.hidden = false

inp2.hidden = false

}

else {

inp1.hidden = true

inp2.hidden= true



}
13 Replies

Avatar

Former Community Member
abc.presence = "visible";

abc.presence = "invisible";



but you must also save the form as a dynamic pdf

ulf.a@dtp-tjanst.se

www.dtp-tjanst.se

Avatar

Former Community Member
Hello Ulf,



Are you saying I should change the property of the other checkboxes from hidden to invisible?



Tx

Avatar

Former Community Member
The presence property is the property to change from visible to invisible or the opposite.

abc.presence = "visible";

Were the name of the checkbox is abc



I have not tried it on checkboxes but it works on other objects



ulf.a@dtp-tjanst.se

www.dtp-tjanst.se

Avatar

Former Community Member
Tried the script still no go, even on a different object such as list box.



Is there a debugger in adobe designer I can run to check for errors?



Tx

Avatar

Former Community Member
I have tested it

Yes you are right

It's a bug because it works on text objects.

Set the radiobuttonlist to Hidden (Excluded from the layout) in the Object, Field pannel

The run a script containing the RadioButtonList.presence="visible";

Remeber that you also have to save the form as dynamic pdf

ulf.a@dtp-tjanst.se

www.dtp-tjanst.se

Avatar

Former Community Member
can you post your script? I still can't get it to work



tx

Avatar

Former Community Member
no problem send me a mail on

ulf.a@dtp-tjanst.se

To get your mail address

You have to wayt a few ours it's sleeping time in sweden

/Ulf

Avatar

Former Community Member
Here is sample JavaScript using "Change" event on CheckBox1 text object in Dynamic PDF form. If CheckBox 1 is checked, CheckBox2 and 3 will be visible, unchecked they will be invisible.



if (this.rawValue == true)

{xfa.form.F.P1.CheckBox2.presence = "visible";

xfa.form.F.P1.CheckBox3.presence = "visible";

}



else

{xfa.form.F.P1.CheckBox2.presence = "invisible";

xfa.form.F.P1.CheckBox3.presence = "invisible";

}

Avatar

Former Community Member
Hi Forrest,



Your script works!



could you point out why the original script didn't work?



Thank you very much for your help.

Avatar

Level 6
> could you point out why the original script didn't work?



Your original script didn't work because you're confusing Acrobat JavaScript with Designer JavaScript. Two different object models with respect to forms.



George

Avatar

Former Community Member
It is the getField function which fails to find the object in the XFA hierarchy. You would have needed to use something like:



event.target.getField("form[0].page1[0].subform1[0].checkbox2[0]");



instead of



this.getField("checkbox2");



The hierarchy was implemented in part to support the XFA specification.



Also, in version 7 this would have caused a security error, so it really is best to go through the XFA object model from now on, if you are using Designer forms.

Avatar

Level 4

I need help.

I am way to new to JavaScript to know what I am doing.  I am getting a syntax error for the following and no idea what is wrong.

Please help!

var myDoc = event.target;

var CashCheckTotal = myDoc.getField(“form1[0].#subform[0].CalculatedCashCheckTotal[0]”);

thank you so much!

jodi