Highlighted

Need help with binding checkboxes

Avatar

Guest

05-02-2009

Hello, this might be noob questions, but I work just 4 days with LiveCycle and I didn't get out the following things.<br /><br />I want to do the following things:<br /><br />1. link two checkboxes together, mostly like those radiobuttons. Only thing, you should be able to edit an entry so if you once placed a choice you can undo it and do none but never be able to choose both checkboxes.<br /><br />I already did: <br />-set programming language to java<br />-write if (this.rawValue == 1){<br /> control.access = "";}<br /> & if (this.rawValue == 1){<br /> controlling.access = "";}<br />In the *change textfields.<br />But somehow nothing of it does initialize. What did I forget???<br /><br />I'll write the XML at the bottom of the message.<br /><br />2. link a checkbox to a textfield. If the checkbox is clicked, the field should be obligatory, if not the field should be write-protected/read only.<br /><br />Is there a special command for making a field obligatory?<br /><br />PS.: I hope I did explain my problems correctly and easy to understand. I would be happy if I get simple answers, since my mother tongue isn't English. It would be sad, if this would get stuck due to understanding problems ;D<br /><br />Thanx already if you would try to help me :)<br /><br />Here the xml code of 1.:<br /><br /> <subform w="197.3mm" h="284.3mm"><br /> <field name="controlling" y="38.1mm" x="6.35mm" w="43.2054mm" h="6mm"><br /> <ui><br /> <checkButton><br /> <border><br /> <?templateDesigner StyleID apcb2?><br /> <edge stroke="lowered"/><br /> <fill/><br /> </border><br /> </checkButton><br /> </ui><br /> <font typeface="Myriad Pro"/><br /> <margin leftInset="1mm" rightInset="1mm"/><br /> <para vAlign="middle"/><br /> <value><br /> <integer>0</integer><br /> </value><br /> <caption placement="right" reserve="28.6004mm"><br /> <para vAlign="middle"/><br /> <font typeface="Myriad Pro"/><br /> <value><br /> <text>-</text><br /> </value><br /> </caption><br /> <items><br /> <integer>1</integer><br /> <integer>0</integer><br /> <integer>2</integer><br /> </items><br /> <event activity="change" name="event__change"><br /> <script contentType="application/x-javascript"><br /><br />if (this.rawValue == 1){<br /> controling.access = "";}</script><br /> </event><br /> </field><br /> <field name="control" y="38.1mm" x="60.325mm" w="43.2054mm" h="6mm"><br /> <ui><br /> <checkButton><br /> <border><br /> <?templateDesigner StyleID apcb2?><br /> <edge stroke="lowered"/><br /> <fill/><br /> </border><br /> </checkButton><br /> </ui><br /> <font typeface="Myriad Pro"/><br /> <margin leftInset="1mm" rightInset="1mm"/><br /> <para vAlign="middle"/><br /> <value><br /> <integer>0</integer><br /> </value><br /> <caption placement="right" reserve="28.6004mm"><br /> <para vAlign="middle"/><br /> <font typeface="Myriad Pro"/><br /> <value><br /> <text>-</text><br /> </value><br /> </caption><br /> <items><br /> <integer>1</integer><br /> <integer>0</integer><br /> <integer>2</integer><br /> </items><br /> </field>

Replies

Highlighted

Niall_O_Donovan

05-02-2009

Hi Lisa,<br /><br />First I would recommend JP Terry's book "Creating Dynamic Forms with Adobe LiveCycle Designer" - it is excellent. <br /><br />In relation to radio buttons and checkboxes he advises that, from a design point of view:<br />(1) Radio buttons should only be used where the user can only make a single choice;<br />(2) Check boxes should be used where the user can select multiple choices from the boxes provided. <br /><br />So for your first question I would recommend that you use radio buttons. If you put the following Javascript in ALL of the radio buttons the user will be able to deselect a choice.<br /><br />In the MOUSE DOWN event:<br /><br />// Capture initial value of radio Button and save it as a member of the radio button object<br />this.initValue = this.rawValue;<br /><br />In the MOUSE UP event:<br /><br />// Test the captured initial value and set the radio button to<br />// off only if the initial value of the radio group is <br />// the same as the export value for this radio button<br />var localExport = null;<br />for(var i=0;i<this.nodes.length;i++)<br />{<br /> if(this.nodes.item(i).className == "items")<br /> {<br /> localExport = this.nodes.item(i).nodes.item(0).value;<br /> break;<br /> }<br />}<br />if(this.initValue == localExport )<br /> this.rawValue = 0;<br /><br />I can't remember which thread I got the script from, but it works a treat if inserted into all radio buttons in a group. We try and use it in all our radio buttons. <br /><br />A possible solution for the second problem, may be to out the following Javascript in the MOUSE UP event of the checkbox (in relation to a field called TextField1):<br /><br />if (this.rawValue == 1) {<br /> TextField1.validate.nullTest = "error";<br /> xfa.layout.relayout();<br />}<br />else {<br /> TextField1.validate.nullTest = "disabled";<br /> xfa.layout.relayout();<br />}<br /><br />Hope that helps, good luck!<br /><br />Niall
Highlighted

Avatar

Guest

05-02-2009

Thank you very much for the first solution 🙂

It works perfectly



Something like the second one was on my mind too, but it should be marked as obligatory field so the user could see this field is obligatory.
Highlighted

Niall_O_Donovan

06-02-2009

Hi Lisa,



In the Javascript above, after the first nullTest line add the following script:



TextField1.border.edge.color.value = "255,0,0";

TextField1.assist.toolTip.value = "This field is mandatory, please provide a response...";



After the second nullTest line add the following script:



TextField1.border.edge.color.value = "255,255,255";

TextField1.assist.toolTip.value = "This field is optional...";



Set the initial tool tip for Textfield1 (in the Accessibility tab) to "This field is optional...".



In addition you may want to add the following Javascript in the exit field of the TextField1 to turn off the red border if the user inputs data:



if (this.rawValue != null) {

this.border.edge.color.value = "255,255,255";

}

if (CheckBox1.rawValue == 1 & this.rawValue == null) {

this.border.edge.color.value = "255,0,0";

}



Regards,



Niall
Highlighted

Avatar

Guest

06-02-2009

Thanks 🙂

Wow you are really fast ^^

That's a really good solution to avoid the problem 🙂



Oh man... oke one last (and most likly the most stupid question).

What do I have to change, if my on/off-Values are Y/N?

(I should have started like this since I only can use y/n as values for radiobuttons as for checkboxes ;( )



I think I already had the solution to this one... but delted it after your programm worked...
Highlighted

Niall_O_Donovan

06-02-2009

Hi Lisa,



Glad to be of help!



I think I see what your issue is. If you are using radio buttons with "Yes" and "No" captions, then in the Object / Binding tab you can specify item values. For example "Yes" would be equal to 1 and "No" would be equal to 0 (zero).



The user sees Yes/No, but the script is working off 1/0.



If you have to use y and n as values. then the if statements would look like:



if (this.rawValue == "y") {

...



Basically replace 1 with "y". The quotation marks are important when dealing with text values.



Good luck,



Niall
Highlighted

Avatar

Guest

06-02-2009

I am such an idiot 😉 everything I tried was much more difficult



Niall you are my hero 🙂



*blows a kiss*



Thank you sooooooooo very much for helping me 🙂