What is wrong with the following code?

  Panel[DynamicModule[{a = RandomInteger[100], b = RandomInteger[100],
   f = a + b}, 
  Column[{InputField[{Dynamic[a], Dynamic[b]}], Dynamic[f]}]]]

Once executed the values in the panel cannot be changed.

Thank you.


1 Answer 1


Work with lists:

 DynamicModule[{a = {RandomInteger[100], RandomInteger[100]}},
  Column[{InputField[Dynamic[a]], Dynamic[Total@a]}]]]


DynamicModule[{b = {RandomInteger[100], RandomInteger[100]}},
 Panel[Column[{InputField[Dynamic[b]], Dynamic[Total@b]}]]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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