I want to create a list of values, True
or False
, and to update those values with a Checkbox
. But the number of elements needs to be arbitrary.
It should look something like the following code which works perfectly fine:
dyn={False,False,False};
A={{1,dyn[[1]]},{2,dyn[[2]]},{3,dyn[[3]]}}
Row@{Checkbox@Dynamic@dyn[[1]],Checkbox@Dynamic@dyn[[2]],Checkbox@Dynamic@dyn[[3]]}
But, of course, it is not practical to write out every iteration of these things. This is the reason that Table
exists. However, when I put everything into tables, it does not work.
n=3;
dyn=Table[False,{i,n}];
A=Dynamic@Table[{i,dyn[[i]]},{i,n}]
Row@Table[Checkbox@Dynamic@dyn[[i]],{i,n}]
The code above results in this error message:
Part::pspec: Part specification i is neither an integer nor a list of integers. >>
I do not understand why Table
and Dynamic
are in conflict with one another. It is as if Dynamic
reaches the i
before Table
and replace it with an iterative value and then Dynamic
has no idea what to do with it. But why is this? Or is the problem something else altogether?
Module
orWith
; using these will allow you to limit the context of your counting variable. $\endgroup$