Why do the group heading and background colour are not changing?

116
6
Jump to solution
08-09-2022 09:07 PM
MaCharmaineMiciano
New Contributor II

Hi,

Can please someone help me? I want to change the heading of the group from INCOMPLETE to COMPLETE once all the questions have been answered and change the background colour into light Green. I tried these expressions from the other forms that I created and they all worked fine except for this one. I uploaded a sample questions in my form.

Thank you for any help.

Charmaine

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Notable Contributor

See attached.  It works fine.  You are not creating your if statements correctly.

Also there is no need for 3 different comment fields.  The schema will be horrible to use.

I also removed the font color since if you have the background and the text the same color you cannot see it. See below

DougBrowning_0-1660656240171.png

 

The attached is much simpler and works.  Hope that helps

View solution in original post

0 Kudos
6 Replies
DougBrowning
MVP Notable Contributor

Your if statement has several issues.  I am not even sure what you are trying to do here so I cannot fix it.

it must always be if(condition, true, false).  You have several if statements just sitting next to each other.

if(string-length(${runoffcontrol})=0,
      0, (true)
       if(string-length(${runoffcontrol})='yes', (false)
             'no', (true)
             'notapplicable', (false - this is where it goes wrong)
             1, (??)
                 if(string-length(${comment4})>0,1,0, (you have a true and false here)
                if(string-length(${comment5})>0,1,0, (you have a true and false here)
                if(string-length(${comment6})>0,1,0))))) (you have a true and false here)

Maybe you are trying to add them up?  If so you want if() + if + if ... etc.  But then you have a NA in there which of course you cannot add.  So not sure.

Hope that helps

0 Kudos
MaCharmaineMiciano
New Contributor II

Hi @DougBrowning ,

Thank you for your help. I just recently started learning how to create forms in the Survey 123. 

Sorry if I didn't explain it clearly in my recent post, but what I want to do here is when all the questions have been answered a word "COMPLETE" will appear in the heading and the background color will also change into "LightGreen". However, when all the questions are not completely answered a word "INCOMPLETE" will appear instead in the heading, and the background color will also change to "LightPink".

Can you please recommend an expression to me on how I will make this happen? or its not possible because of the "notapplicable" option in the choices?

Thank you again for any help.

Regards

Charmaine

 

 

 

0 Kudos
DougBrowning
MVP Notable Contributor

There are just several logic errors with your if statement.  If you want when all are answered just use a and. 

if(string-length(${runoffcontrol}) > 0 and string-length(${comment4}) > 0 and string-length(${comment5}) > 0, "LightGreen", "LightPink")

0 Kudos
MaCharmaineMiciano
New Contributor II

Thank you for your help @DougBrowning .

I tried the syntax above that you suggested, but it was not working. I wonder what's wrong.

0 Kudos
DougBrowning
MVP Notable Contributor

See attached.  It works fine.  You are not creating your if statements correctly.

Also there is no need for 3 different comment fields.  The schema will be horrible to use.

I also removed the font color since if you have the background and the text the same color you cannot see it. See below

DougBrowning_0-1660656240171.png

 

The attached is much simpler and works.  Hope that helps

0 Kudos
MaCharmaineMiciano
New Contributor II

Thank you heaps @DougBrowning for your help. I still need to learn more.