Expand my Community achievements bar.

SOLVED

need script to hide and view checkboxes

Avatar

Level 2

Hello, basically I have two checkboxes that are names "In good order" and "Not in good order." What I want to do is if the checkbox for "In good order" is checked then "Not in good order" disappears and vice versa.  I managed to write the script for that however I also need "Not in good order" to reappear if "In good order" is unchecked just in case the client checked the wrong box they can still see the other option and check it.  How do I do that?  Please help!  Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

For check box 1 add the following script to the change event, where the form is called 'form1', the default sub-form is called 'page1' and the check box is called 'cb1'.

// form1.page1.cb1::change - (JavaScript, client)


if (form1.page1.cb1.rawValue == 1) {

  form1.page1.cb2.presence = "hidden";

}

else {

  form1.page1.cb2.presence = "visible";

}

For check box 2 add the following script to the change event, where the form is called 'form1', the default subform is called 'page1' and the check box is called 'cb2'.

// form1.page1.cb2::change - (JavaScript, client)


if (form1.page1.cb2.rawValue == 1) {

  form1.page1.cb1.presence = "hidden";

}

else {

  form1.page1.cb1.presence = "visible";

}

Remember, before you test the form, save it as a dynamic PDF.

Steve

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

For check box 1 add the following script to the change event, where the form is called 'form1', the default sub-form is called 'page1' and the check box is called 'cb1'.

// form1.page1.cb1::change - (JavaScript, client)


if (form1.page1.cb1.rawValue == 1) {

  form1.page1.cb2.presence = "hidden";

}

else {

  form1.page1.cb2.presence = "visible";

}

For check box 2 add the following script to the change event, where the form is called 'form1', the default subform is called 'page1' and the check box is called 'cb2'.

// form1.page1.cb2::change - (JavaScript, client)


if (form1.page1.cb2.rawValue == 1) {

  form1.page1.cb1.presence = "hidden";

}

else {

  form1.page1.cb1.presence = "visible";

}

Remember, before you test the form, save it as a dynamic PDF.

Steve

Avatar

Level 10

Try like this..

Place two check boxes and put the below code in CheckBox1 Click event.

if(CheckBox1.rawValue ==1)
CheckBox2.presence = "hidden";
else
CheckBox2.presence = "visible";

Place the below code in CheckBox2 Click event.

if(CheckBox2.rawValue ==1)
CheckBox1.presence = "hidden";
else
CheckBox1.presence = "visible";

Thanks

Srini

Avatar

Level 2

Thank you again Steve!  And thank you too Srini!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----