BookmarkSubscribeRSS Feed
Highlighted
DjakFrost

Community Member

Joined:

Nov 13, 2018

Update NE Box from Cell in Same Row of Table Referenced by Combo Box

Hello all

 

I've been trying to update a script handed down to me, and while I've had a lot of success with it, one item keeps tripping me up. Instead of having users enter a height and width (used later in the script to generate a bivariate map), I want to have the option to auto-poplulate those values in number edit boxes (in case the user still wants to input the values manually) based on the values that correspond to a part name in a table. Modifying the example I found, it would be something like this:

 

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
Summarize( a = By( :name ) );
Insert Into( a, "<Select Name>", 1 );
New Window( "Example",
	<<Modal,
	H List Box(
		/* Upon selecting a name, populate the Number Edit Boxes with corresponding age/weight */
		Panel Box( "Select a Name:",
			cb1 = Combo Box(
				a,
				<<SetFunction(
					Function( {this},
						selection = this << Get Selected();
						r = dt << Get Rows Where( :name == Num( selection ) );
						NameAge = :age[r];
						ne1 << Set Items( NameAge );
					)
				);
				<<SetFunction(
					Function( {that},
						selection2 = that << Get Selected();
						q = dt << Get Rows Where( :weight == Num( selection2 ) );
						NameWeight = :weight[q];
						ne2 << Set Items( NameAge );
					)
				);
			)
		),
		Panel Box( "Select an Age:",
			ne1 = Number Edit Box(
				<<SetFunction(
					Function( {this},
						Print( selection, this << Get Selected() )
					)
				)
			)
		),
		Panel Box( "Select a Weight:",
			ne2 = Number Edit Box(
				<<SetFunction(
					Function( {that},
						Print( selection2, that << Get Selected() )
					)
				)
			)
		),
	)
);