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.

Selecting check box creates text entry field to enter info ?

Avatar

Level 1

hi, I am very new to livecycle.  Bought it on last day availble actually...

i am trying to make an interview form, and there’s Zaire 4 possible questions in each section but only 2 need to be used per section.   I would like to figure out how to make it that when a checkbox is selected it opens up a text feild below it for details to be entered. 

If if you can help that would be most appreciated

btw i do not know javascripting.

Thabks... Brian

2 Replies

Avatar

Level 7

Hi Brian,

If you are very new to it, I would suggest doing these tutorials at the link below. It helped me immensely when I started out. It might also help you to understand my solution without me having to go into extra details.

Adobe LiveCycle ES4 * About the Quick Start Tutorials

There are a number of things to consider. If you are allowing two selections, you will need to use checkboxes rather than radio button groups. You will need to add code to the radio button so only a maximum of 2 can be selected. When checking a radio button, it should unhide the textfield.

For my demo, i have added four checkboxes and four textfields, one for each.

1701150_pastedImage_4.png

Showing and hiding a textField.

This code will show or hide a textfield.

if(this.rawValue == "1") //when checked, show TextField
{
TextField1.presence = "visible";
}

if(this.rawValue == "0") //when unchecked, hide TextField
{
TextField1.presence = "hidden";
}

1701149_pastedImage_3.png

The code needs to be modified to restrict checkbox usage. Still in the change event, edit the code.

Restricting the selection of two checkBoxes only.

This can be a little hard to get your head around. You need to add more logic to handle the restriction of the checkboxes. Basically, if a checkbox is checked, have a look to see if others are checked. If another is checked, make the remaining two checkboxes readOnly. You also need to add code so that if a box is unchecked, you have access again to the checkboxes.

If you can master 'if' logic, you will go far.

This is the code for my four checkboxes:

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

if(this.rawValue == "1") //when checked, show TextField
{
TextField1.presence = "visible";
if(CheckBox2.rawValue == "1") //if CheckBox2 is already checked, make the others readOnly
{
CheckBox3.access = "readOnly";
CheckBox4.access = "readOnly";
}

if(CheckBox3.rawValue == "1") //if CheckBox3 is already checked, make the others readOnly
{
CheckBox2.access = "readOnly";
CheckBox4.access = "readOnly";
}

if(CheckBox4.rawValue == "1") //if CheckBox4 is already checked, make the others readOnly
{
CheckBox2.access = "readOnly";
CheckBox3.access = "readOnly";
}
}

if(this.rawValue == "0") //when unchecked, hide TextField and allow access to other checkboxes
{
TextField1.presence = "hidden";
CheckBox2.access = "open";
CheckBox3.access = "open";
CheckBox4.access = "open";
}

form1.#subform[0].CheckBox2::change - (JavaScript, client)

if(this.rawValue == "1") //when checked, show TextField
{
TextField2.presence = "visible";
if(CheckBox1.rawValue == "1") //if CheckBox1 is already checked, make the others readOnly
{
CheckBox3.access = "readOnly";
CheckBox4.access = "readOnly";
}

if(CheckBox3.rawValue == "1") //if CheckBox3 is already checked, make the others readOnly
{
CheckBox1.access = "readOnly";
CheckBox4.access = "readOnly";
}

if(CheckBox4.rawValue == "1") //if CheckBox4 is already checked, make the others readOnly
{
CheckBox1.access = "readOnly";
CheckBox3.access = "readOnly";
}
}

if(this.rawValue == "0") //when unchecked, hide TextField and allow access to other checkboxes
{
TextField2.presence = "hidden";
CheckBox1.access = "open";
CheckBox3.access = "open";
CheckBox4.access = "open";
}

form1.#subform[0].CheckBox3::change - (JavaScript, client)
if(this.rawValue == "1") //when checked, show TextField
{
TextField3.presence = "visible";
if(CheckBox1.rawValue == "1") //if CheckBox1 is already checked, make the others readOnly
{
CheckBox2.access = "readOnly";
CheckBox4.access = "readOnly";
}

if(CheckBox2.rawValue == "1") //if CheckBox2 is already checked, make the others readOnly
{
CheckBox1.access = "readOnly";
CheckBox4.access = "readOnly";
}

if(CheckBox4.rawValue == "1") //if CheckBox4 is already checked, make the others readOnly
{
CheckBox1.access = "readOnly";
CheckBox2.access = "readOnly";
}
}

if(this.rawValue == "0") //when unchecked, hide TextField and allow access to other checkboxes
{
TextField3.presence = "hidden";
CheckBox1.access = "open";
CheckBox2.access = "open";
CheckBox4.access = "open";
}

form1.#subform[0].CheckBox4::change - (JavaScript, client)
if(this.rawValue == "1") //when checked, show TextField
{
TextField4.presence = "visible";
if(CheckBox1.rawValue == "1") //if CheckBox1 is already checked, make the others readOnly
{
CheckBox3.access = "readOnly";
CheckBox2.access = "readOnly";
}

if(CheckBox3.rawValue == "1") //if CheckBox3 is already checked, make the others readOnly
{
CheckBox1.access = "readOnly";
CheckBox2.access = "readOnly";
}

if(CheckBox2.rawValue == "1") //if CheckBox4 is already checked, make the others readOnly
{
CheckBox1.access = "readOnly";
CheckBox3.access = "readOnly";
}
}

if(this.rawValue == "0") //when unchecked, hide TextField and allow access to other checkboxes
{
TextField4.presence = "hidden";
CheckBox1.access = "open";
CheckBox3.access = "open";
CheckBox2.access = "open";
}

Avatar

Level 1

Thank you very much, I will be trying that at my earliest next opportunity. 

You are very gracious with your help, thanks again

Brian