Have an idea?

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

ACBC - Number of concepts per screening task

Hi,
I use 'Number of concepts per screening task=3' as I have only 3 attributes in my study and use HTML/PERL code to print 'Product 1', 'Product 2' & 'Product 3' at the top of the screening task. The problem is when it goes on, survey suddenly shows only 2 concepts but the header remains same. For 2 concepts it shows 'Product 1', 'Product 2' & 'Product 3' at the top. I would like to return a number which says number of concepts showing in current screener, Is it possible?
I can able to adjust my HTML/PERL script based on this number.
Please help me to get that number.
asked Sep 7, 2016 by Abdul Bronze (2,630 points)

1 Answer

0 votes
 
Best answer
I'm not aware of any way to do this in Perl, but it can be easily done in JavaScript.  This code should return the number of concepts being shown on the page:

$('tr.acbc_task_top_row > td').length - 1


You can then use a for loop in the JavaScript to add the desired number of headers to the table.
answered Sep 7, 2016 by Zachary Platinum Sawtooth Software, Inc. (147,925 points)
selected Sep 8, 2016 by Abdul
Hi Zachary,
Thanks for replying.
It returns value -1. Could you please advice?
<script type="text/javascript">
var scnum=$('tr.acbc_task_top_row > td').length - 1;
alert("My value at this point is: " + scnum);
</script>
The code is likely running before the HTML table has finished loading.  Putting the code inside of a "ready" function should ensure that the code does not run until the table has finished loading.

<script>
$(document).ready(function(){
    var scnum=$('tr.acbc_task_top_row > td').length - 1;
    alert("My value at this point is: " + scnum);
})
</script>
Thanks Zachary.
...