I'm trying to make a square matrix of InputFields, where the size is dependent on what the user chooses. Each cell should be independent of each other.

Here's what I tried:

dimension = 3;
inputA = Partition[Table[
           InputField[Dynamic[a[i], Function[If[# =!= Null && IntegerQ[#], a[i] = #]]], 
                      Number, FieldSize -> 4], 
                      {i, dimension^2}], dimension];

But when I run this, all of the cells are assigned as one variable, so if I put in a number in any of the cells, the rest of the cells auto-populate to that number. I am lost as to what I'm doing wrong here. Why doesn't the table assign the cells as a[1], a[2], and so on?


Following the tutorial pointed to by wuyingddg,

dim = 3; a = ConstantArray[0, dim^2]; 
Partition[Table[With[{i = i}, InputField[Dynamic[a[[i]]]]], 
               {i, dim^2}], dim] // TableForm
|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.