Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Header Color in ACBC Screener section

Hi,

I am using the following code to show header text with color to match concept column color. It looks good for odd number screening concepts (For example: "DVB_Screener1", "DVB_Screener3", DVB_Screener5", DVB_Screener7"), when it comes to even number the color doesn't match with the concept column color.

FYI: In the study, it shows 4 concepts in some screen and only 3 in some others, that is why we use 'for' loop and all.

<script>
$(document).ready(function(){
    var scnum=$('tr.acbc_task_top_row > td').length - 1;
    var topRowHtml = '<tr><td></td>';
    for (i = 1; i <= scnum; i++)
    {
      if (i % 2 == 1)
      {topRowHtml += '<td bgcolor="#E0E0E0"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';}
      else
      {topRowHtml += '<td bgcolor="#C3C3C3"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';}
    
    }
    topRowHtml += '</tr>';
    $('.acbc_screener > .question_body > table > tbody').prepend(topRowHtml);
})
</script>


I want the above code to be altered that to be worked for all screening sections.

In simple, the following codes to be interchanged based on screening section.
      {topRowHtml += '<td bgcolor="#E0E0E0"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';}
      else
      {topRowHtml += '<td bgcolor="#C3C3C3"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';}


Any suggestions?
asked May 17, 2017 by Abdul Bronze (2,630 points)
edited May 17, 2017 by Abdul

1 Answer

+1 vote
 
Best answer
You can use the modulo operator on the screener number to know whether you are on an even or odd screener task:

[%ACBCCurrentScreener()%] % 2 == 1


Here's a simple example:

if ([%ACBCCurrentScreener()%] % 2 == 1 && i % 2 == 1) {
    topRowHtml += '<td bgcolor="#E0E0E0"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';
}
else if ([%ACBCCurrentScreener()%] % 2 == 1 && i % 2 == 0) {
    topRowHtml += '<td bgcolor="#C3C3C3"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';
}
else if ([%ACBCCurrentScreener()%] % 2 == 0 && i % 2 == 1) {
    topRowHtml += '<td bgcolor="#C3C3C3"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';
}
else if ([%ACBCCurrentScreener()%] % 2 == 0 && i % 2 == 0) {
    topRowHtml += '<td bgcolor="#E0E0E0"><center><font size="3"><b>Product ' + i + '</b></font></center></td>';
}
answered May 17, 2017 by Zachary Platinum Sawtooth Software, Inc. (148,225 points)
selected May 17, 2017 by Abdul
Thanks a lot for your help!. It works great.
...