cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-527364%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%E9%99%84%E5%8A%A0%E6%97%A5%E6%9B%86%E6%A1%86%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-527364%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%98%97%E8%A9%A6%E5%89%B5%E5%BB%BA%E4%B8%80%E5%80%8B%E7%94%A8%E6%88%B6%E4%BB%8B%E9%9D%A2%E4%BE%86%E9%81%B8%E6%93%87%E6%97%A5%E6%9C%9F%E3%80%82%E6%88%91%E6%96%B0%E5%A2%9E%E4%BA%86%E4%B8%80%E5%80%8B%E6%8C%89%E9%88%95%E6%A1%86%EF%BC%8C%E5%AE%83%E5%B0%87%E6%97%A5%E6%9B%86%E6%A1%86%E9%99%84%E5%8A%A0%E5%88%B0%E9%9D%A2%E6%9D%BF%E6%A1%86%EF%BC%8C%E4%BD%86%E6%AF%8F%E6%AC%A1%E5%96%AE%E6%93%8A%E6%99%82%EF%BC%8C%E5%AE%83%E9%83%BD%E6%9C%83%E4%B8%8D%E6%96%B7%E5%90%91%E9%9D%A2%E6%9D%BF%E6%A1%86%E6%B7%BB%E5%8A%A0%E5%85%83%E7%B4%A0%E3%80%82%E6%88%91%E6%83%B3%E5%9C%A8%E7%AC%AC%E4%BA%8C%E6%AC%A1%E5%96%AE%E6%93%8A%E6%99%82%E9%9A%B1%E8%97%8F%E6%97%A5%E6%9B%86%E6%A1%86%E3%80%82%E6%9C%89%E8%BE%A6%E6%B3%95%E5%AF%A6%E7%8F%BE%E9%80%99%E4%B8%80%E9%BB%9E%E5%97%8E%EF%BC%9F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jacksmith12_0-1658970097030.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jacksmith12_0-1658970097030.png%22%20style%3D%22width%3A%20291px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F44392iD3777B35E963C2AC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jacksmith12_0-1658970097030.png%22%20alt%3D%22Jacksmith12_0-1658970097030.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E9%80%99%E6%98%AF%E6%88%91%E7%9A%84%E7%A8%8B%E5%BC%8F%E7%A2%BC%EF%BC%9A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Esd%3DToday()%3B%0Aed%3DToday()%3B%0ANew%20Window(%20%22Query%20Date%22%2C%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3CLINGO-LABS%20id%3D%22lingo-labs-527364%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CLINGO-LABEL%3E%E9%80%B2%E9%9A%8E%E7%B5%B1%E8%A8%88%E5%BB%BA%E6%A8%A1%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E6%B6%88%E8%B2%BB%E8%80%85%E8%88%87%E5%B8%82%E5%A0%B4%E7%A0%94%E7%A9%B6%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E8%B3%87%E6%96%99%E6%B7%B7%E5%90%88%E8%88%87%E6%B8%85%E7%90%86%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E5%93%81%E8%B3%AA%E5%92%8C%E5%B7%A5%E8%97%9D%E5%B7%A5%E7%A8%8B%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3C%2FCODE%3E%3CLINGO-SUB%20id%3D%22lingo-sub-527646%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E8%BF%BD%E5%8A%A0%E6%97%A5%E6%9B%86%E6%A1%86%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-527646%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%8F%AA%E6%98%AF%E7%82%BA%E4%BA%86%E6%93%B4%E5%A4%A7%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2687%22%20target%3D%22_blank%22%3E%40txnelson%3C%2FA%3E%E7%9A%84%E5%BB%BA%E8%AD%B0%EF%BC%8C%E9%80%99%E6%98%AF%E5%8F%A6%E4%B8%80%E5%80%8B%E3%80%82%20%E5%AE%83%E5%8F%AA%E6%98%AF%E8%AA%AA%E6%98%8E%E4%BA%86%E4%B8%80%E7%A8%AE%E6%8A%80%E8%A1%93%E3%80%82%20%E7%84%A1%E8%AB%96%E5%A6%82%E4%BD%95%EF%BC%8C%E5%AE%83%E9%83%BD%E4%B8%8D%E6%98%AF%E4%B8%80%E5%80%8B%E5%AE%8C%E6%95%B4%E7%9A%84%E8%85%B3%E6%9C%AC%E3%80%82%20%E5%AE%83%E9%82%84%E8%A1%A8%E6%98%8E%EF%BC%8C%E5%B0%87%E6%97%A5%E6%9C%9F%E6%A0%BC%E5%BC%8F%E8%88%87%E6%95%B8%E5%AD%97%E7%B7%A8%E8%BC%AF%E6%A1%86%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8%E5%B0%87%E8%87%AA%E5%8B%95%E6%8F%90%E4%BE%9B%E6%97%A5%E6%9B%86%E9%81%B8%E9%A0%85%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0Asd%20%3D%20ed%20%3D%20Today()%3B%0Avisible%20%3D%200%3B%0A%0ANew%20Window(%20%22Query%20Date%22%2C%0A%20%26lt%3B%26lt%3B%20Modal%2C%0A%20Panel%20Box(%20%22From%20Time%22%2C%0A%20%20Line%20Up%20Box(%20N%20Col(%203%20)%2C%0A%20%20%20Text%20Box(%20%22Start%22%20)%2C%0A%20%20%20Number%20Edit%20Box(%20sd%2C%0A%20%20%20%20%26lt%3B%26lt%3B%20Set%20Format(%20Format(%20%22m%2Fd%2Fy%22%2C%2012%20)%20)%0A%20%20%20)%2C%0A%20%20%20cb1%20%3D%20Calendar%20Box(%20%26lt%3B%26lt%3B%20Visibility(%20Collapse%20)%20)%2C%0A%20%20%20Text%20Box(%20%22End%22%20)%2C%0A%20%20%20Number%20Edit%20Box(%20ed%2C%0A%20%20%20%20%26lt%3B%26lt%3B%20Set%20Format(%20Format(%20%22m%2Fd%2Fy%22%2C%2012%20)%20)%0A%20%20%20)%2C%0A%20%20%20cb2%20%3D%20Calendar%20Box(%20%26lt%3B%26lt%3B%20Visibility(%20Collapse%20)%20)%0A%20%20)%0A%20)%2C%0A%20bb%20%3D%20Button%20Box(%20%22Show%20Calendars%22%2C%0A%20%20If(%20visible%2C%0A%20%20%20%7B%20cb1%2C%20cb2%20%7D%20%26lt%3B%26lt%3B%20Visibility(%20Collapse%20)%3B%0A%20%20%20bb%20%26lt%3B%26lt%3B%20Set%20Button%20Name(%20%22Show%20Calendars%22%20)%2C%0A%20%20%20%7B%20cb1%2C%20cb2%20%7D%20%26lt%3B%26lt%3B%20Visibility(%20Visible%20)%3B%0A%20%20%20bb%20%26lt%3B%26lt%3B%20Set%20Button%20Name(%20%22Hide%20Calendars%22%20)%3B%0A%20%20)%3B%0A%20%20visible%20%3D%20!visible%3B%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-527404%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E8%BF%BD%E5%8A%A0%E6%97%A5%E6%9B%86%E6%A1%86%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-527404%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E9%80%99%E6%98%AF%E4%B8%80%E7%A8%AE%E8%99%95%E7%90%86%E6%96%B9%E6%B3%95%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Asd%20%3D%20Today()%3B%0Aed%20%3D%20Today()%3B%0Aflag%20%3D%200%3B%0ANew%20Window(%20%22Query%20Date%22%2C%0A%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Jackie_
Level VI

Append calendar box

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?

Jacksmith12_0-1658970097030.png

 

Here's my code:

sd=Today();
ed=Today();
New Window( "Query Date", <<Modal,
 HListBox(
   Panel1= PanelBox( "From Time"),
   	Button Box("click",
   	Panel1 << removeALl;
   	Panel1 << Append(scal1 = Calendar Box(, SetFunction(Function({this}, sd1=scal1<< Get Date) )));
   )
      
    )

);
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Append calendar box

Here is one way to handle it

Names Default To Here( 1 );
sd = Today();
ed = Today();
flag = 0;
New Window( "Query Date",
	<<Modal,
	H List Box(
		Panel1 = Panel Box( "From Time" ),
		Button Box( "click",
			If( flag == 0,
				Panel1 << removeALl;
				Panel1 << Append( scal1 = Calendar Box( , SetFunction( Function( {this}, sd1 = scal1 << Get Date ) ) ) );
				flag = 1;
			,
				scal1 << visibility( "collapse" )
			)
      
		)
	)
);
Jim

View solution in original post

Re: Append calendar box

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;
	)
);

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Append calendar box

Here is one way to handle it

Names Default To Here( 1 );
sd = Today();
ed = Today();
flag = 0;
New Window( "Query Date",
	<<Modal,
	H List Box(
		Panel1 = Panel Box( "From Time" ),
		Button Box( "click",
			If( flag == 0,
				Panel1 << removeALl;
				Panel1 << Append( scal1 = Calendar Box( , SetFunction( Function( {this}, sd1 = scal1 << Get Date ) ) ) );
				flag = 1;
			,
				scal1 << visibility( "collapse" )
			)
      
		)
	)
);
Jim

Re: Append calendar box

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;
	)
);

Recommended Articles