2
$\begingroup$

I have 4 InputFields.I want to find which InputField was recently Updated out of all InputFields.For that purpose I wrote the following code.

 fValues = {Null, Null, Null, Null};
 {
  Table[
    With[
        {i = i},
        (
                InputField[
                            Dynamic[Part[fValues, i]],
                            Number,
                            ContinuousAction -> True
                        ]
            )
        ],
    {i, 1, 4}
],
Dynamic[fValues]
}

How can I resolve this?

Can anyone help me?

Thank you

$\endgroup$
2
  • $\begingroup$ Could you please tell us why do you keep using so much whitespace with your code formatting? I am simply curious. $\endgroup$ May 2, 2013 at 11:24
  • $\begingroup$ @IstvánZachar For my code maintenance and understanding purpose,every time I following indentation Styels. $\endgroup$
    – subbu
    May 2, 2013 at 11:42

1 Answer 1

2
$\begingroup$

You can use the second argument to Dynamic:

DynamicModule[{fValues, msg, processChanges},
 fValues = {Null, Null, Null, Null};
 msg = "No change yet";
 processChanges[field_, oldvalue_, newvalue_] := 
  msg = Row[{field, " was changed from ", oldvalue, " to ", newvalue}];

 {Table[With[{i = i}, (InputField[
      Dynamic[Part[fValues, i], processChanges[i, fValues[[i]], fValues[[i]] = #] &],
      Number, ContinuousAction -> True])], {i, 1, 4}],
  Dynamic[fValues], 
  Dynamic[msg]}
 ]
$\endgroup$

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.