Hi,
I am trying to create a UI to select dates. I have added a button box which will append calendar box to the panel box but every time I click, it will keep adding elements to the panel box. I want to hide the calendar box on second click. Is there a way to achieve this?

Here's my code:
sd=Today();
ed=Today();
New Window( "Query Date", <<MODAL></MODAL>
Just to expand on @txnelson's suggestion, here is another. It only illustrates a technique. It is not a complete script by any means. It also shows that using a date format with the Number Edit Box will automatically provide a calendar option.
Names Default To Here( 1 );
sd = ed = Today();
visible = 0;
New Window( "Query Date",
<< Modal,
Panel Box( "From Time",
Line Up Box( N Col( 3 ),
Text Box( "Start" ),
Number Edit Box( sd,
<< Set Format( Format( "m/d/y", 12 ) )
),
cb1 = Calendar Box( << Visibility( Collapse ) ),
Text Box( "End" ),
Number Edit Box( ed,
<< Set Format( Format( "m/d/y", 12 ) )
),
cb2 = Calendar Box( << Visibility( Collapse ) )
)
),
bb = Button Box( "Show Calendars",
If( visible,
{ cb1, cb2 } << Visibility( Collapse );
bb << Set Button Name( "Show Calendars" ),
{ cb1, cb2 } << Visibility( Visible );
bb << Set Button Name( "Hide Calendars" );
);
visible = !visible;
)
);Here is one way to handle it
Names Default To Here( 1 );
sd = Today();
ed = Today();
flag = 0;
New Window( "Query Date",
<<MODAL></MODAL>