1

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:

Clear["Global`*"]
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?

J_Nat
  • 346
  • 1
  • 12

1 Answers1

1

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
bill s
  • 68,936
  • 4
  • 101
  • 191