0

The code PopupMenu[Dynamic@x, {a, b, c}] yields a popup menu, and choosing an item stores its value in x.

I'd like to do this (say) three times, in a table, so that the results are stored in three variables called Subscript[x,i], where i is the table counter. Something like:

Table[PopupMenu[Dynamic@Subscript[x, i], {a, b, c}], {i, 3}]

So, if someone picked c from the second popup in the resulting list, then Subscript[x,2] would now have the value c, but the others would remain unchanged.

The above code ignores the subscripted variable, and all three popups take on the same value. Any suggestions?

rhomboidRhipper
  • 856
  • 4
  • 7

1 Answers1

1

You could use With:

Table[PopupMenu[With[{i = i}, Dynamic@Subscript[x, i]], {a, b, c}], {i, 3}]
halmir
  • 15,082
  • 37
  • 53