Expand my Community achievements bar.

SOLVED

CheckBox types/ styles?

Avatar

Level 3

Hi! I´m new to LiveCycle but I have a little idea of Javascript.

I´m struggling with this form that has two sets of options and I have some conditions:

  • If OPTION A is selected I´m not able to select neither OPTION B nor OPTION AA
  • If OPTION B is selected I´m not able to select neither OPTION A nor OPTION BB

What I did is if OPTION A is selected OPTION B presence is set to hidden, but I don´t want the option to just disappear, I´d like (if possible) to show it with a strike trough line or something like that, so you see that if you choose one option you disable the other option. Does this makes sense?

Thanks!

options.png

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Set .access = "readOnly" instead of .presence. You'll also have to set the font to strike through in script as well if you want that.

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

Set .access = "readOnly" instead of .presence. You'll also have to set the font to strike through in script as well if you want that.

Avatar

Level 3

Thanks Steve!

It worked perfectly, what I can't do is to set the font to striketrough, and how is the "normal" access instead of read only???

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

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

                 CheckBox2.access = "readOnly" ;

                    // this is not working, the font remains the same

                 CheckBox2.font.underline = "strikethrough"

    }

          else {

       //I need to set the access back to "normal"

     // and the font to "not striketrough"

          }

Thanks again!

Avatar

Level 3

I got it!

CheckBox1.access = "readOnly" ;

CheckBox1.font.lineThrough = "1";

and to go back to the original state

CheckBox1.access = "open";

CheckBox1.font.lineThrough = "0";

now I have a new problem, there is a combination of checks and unchecks that gives an unwanted situation, please see images attached:

This is the initial situation:

01.png

If I click Video Monitor I disable Meal Tray and Video Monitor, everything fine so far:

02.png

If I click Meal Tray is OK (because is suposed to also disable the same options Video Monitor disabeled in the first place):

03.png

But here is the thing, if I uncheck Video Monitor (or Meal Tray) the code doesn't know that Meal Tray is still checked and returns the disabeled options to its original state, which is not correct (because if you click Meal Tray it disables the other meal tray and the other video monitor):

04.png

Here is the code up to now (the same on each checkbox, but changing which checkbox is modified):

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

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

                 CheckBox3.access = "readOnly" ;

                 CheckBox3.font.lineThrough = "1";

                 CheckBox10.access = "readOnly" ;

                 CheckBox10.font.lineThrough = "1";

    }

          else {

                         CheckBox3.access = "open";

                         CheckBox3.font.lineThrough = "0";

                         CheckBox10.access = "open";

                         CheckBox10.font.lineThrough = "0";

          }

Any ideas???

Thanks!!

Avatar

Level 3

I think I fixed it, I mean, it works the way i want to but i don't know if it's coded correctly:

if (this.rawValue == "1" || CheckBox12.rawValue == "1") {

                 CheckBox3.access = "readOnly" ;

                 CheckBox3.font.lineThrough = "1";

       

   

                 CheckBox10.access = "readOnly" ;

                 CheckBox10.font.lineThrough = "1";

    }

          else {

       

                    CheckBox3.access = "open";

                    CheckBox3.font.lineThrough = "0";

 

                    CheckBox10.access = "open";

                    CheckBox10.font.lineThrough = "0";

          }

Avatar

Former Community Member

A quick way to figure out what to set a value to in script that you can set at design time is to click the field, then go to the XML source tab and see what was changed in the XML.

Avatar

Former Community Member

If there is any weirdness changing your check box with say tabbing to the filed and pressing the space bar, you might want to put the code in the change event. You may also need to use xfa.event.newText instead of rawValue just for the item on which the change event is firing.

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] ----