2
$\begingroup$

I have a Panel with 4 Inputfields and a Button. When a Button is clicked, it shifts itself and adds two Inputfields in its place. Before clicking Button,

enter image description here

and after clicking Button.

enter image description here

I want to know how can I shift Button ?

$\endgroup$
5
$\begingroup$

You could use Dynamic as in :

iField = Table[InputField[], {i, 2}, {j, 2}];

Panel[Dynamic@Grid[Join[iField, {{Button["Add", 
   AppendTo[iField, {InputField[], InputField[]}]], ""}}]]]
$\endgroup$
3
$\begingroup$

A recursive solution would allow for the fields to stay intact when adding

DynamicModule[{var = False},
    Column[{Grid[{{InputField[], InputField[]}}],
      Dynamic[If[var, #0[], Button["Add", var = True]]
       ]}]
    ] &[] // Panel

However, you won't be able to go above approximately 50 I think

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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