# How to stop Dynamic from returning Null?

This question grew out of this other one: DynamicModule not working when additional code is included.

colour = "red";
Panel[
Column[{
InputField[colour, String],
Do[
n1 = 4,
{i, 1, 3}
],
InputField[colour, String]
}]
]


The output is the following:

The Do loop returns a Null, which shows up as a blank space between the two text boxes. Now use DeleteCases to get rid of the Null:

colour = "red";
Panel[
Column[
DeleteCases[
{
InputField[colour, String],
Do[
n1 = 4,
{i, 1, 3}
],
InputField[colour, String]
}, Null]
]
]


And the output is now without the Null:

Now add a Dynamic (which I need for the other question I referred to), as follows:

colour = "red";
Panel[
Column[
DeleteCases[
{
InputField[colour, String],
Dynamic[Do[
n1 = 4,
{i, 1, 3}
]],
InputField[colour, String]
}, Null]
]
]


And here is the output:

In other words, Dynamic seems to be shielding from the action of DeleteCases. Is there any way to get rid of the Null in the output in this third case?

Many thanks.

• Why are you performing Do loop in a Column? p.s. the reason why is: mathematica.stackexchange.com/questions/5817/… – Kuba Nov 15 '16 at 19:25
• Good question! The short answer is that I need a prototype of an interactive query tool: user enters a name in the first textbox, the name is matched in a Do loop here but eventually with a mysql query, and the array index corresponding to the name is used to display a time series in the third element of this column. For this question I used another textbox but the question this refers to shows a plot. I have no idea if this is a dumb way to code it. I have not used MMA's GUI before so I am in hacking mode at the moment. ACL's answer is excellent, thanks for the pointer! – pdini Nov 15 '16 at 22:48

You need to display the content of Dynamic, otherwise it won't evaluate. However, you can hide it if you combine your inputs like this:
colour = "red";