cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Djtjhin
Level IV

Dynamic Display box based on user selection

How to dynamically update a window based on user selection from either a combo box selection or radio box ?

 

I've gone so far as trying out the script below but instead of replacing the text box, it kept appending new text boxes. How to update the script to change the display based on selection ?

I'm planning to incorporate more things beyond just text boxes (i.e. button boxes, col list boxes, etc).

 

Appreciate the help

 

nw1 = new window("New Test",
	tab box(
		TB = Tab page box("Analysis",
			V list box(
				H list box(
					combo1 = combobox({"","Normal","Lognormal"},
						<<setfunction(
							function({this,index},
								match(index,
									1,TB << append (text box("number 1")),
									2,TB << append (text box("number 2")),
									3,TB << append (text box("number 3")),
								)
							)
						)
					)
				)
			)
		)
	)
)
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Dynamic Display box based on user selection

You need to delete the previous text box, otherwise it will just keep adding them.

nw1 = New Window( "New Test",
	Tab Box(
		TB = Tab Page Box(
			"Analysis",
			V List Box(
				H List Box(
					combo1 = Combo Box(
						{"", "Normal", "Lognormal"},
						<<setfunction(
							Function( {this, index},
								Match( index,
									1,
										TB << append(
											Try( tba << delete );
											tba = Text Box( "number 1" );
										),
									2,
										TB << append(
											Try( tba << delete );
											tba = Text Box( "number 2" );
										),
									3,
										TB << append(
											Try( tba << delete );
											tba = Text Box( "number 3" );
										),

								)
							)
						)
					)
				)
			)
		)
	)
)

Or you can just have an empty text box and change it's value

nw1 = New Window( "New Test",
	Tab Box(
		TB = Tab Page Box(
			"Analysis",
			V List Box(
				H List Box(
					combo1 = Combo Box(
						{"", "Normal", "Lognormal"},
						<<setfunction(
							Function( {this, index},
								Match( index,
									1, tba << settext( "number 1" ),
									2, tba << settext( "number 2" ),
									3, tba << settext( "number 3" ), 
								)
							)
						)
					)
				),
				tba = Text Box( "" )
			)
		)
	)
)
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Dynamic Display box based on user selection

You need to delete the previous text box, otherwise it will just keep adding them.

nw1 = New Window( "New Test",
	Tab Box(
		TB = Tab Page Box(
			"Analysis",
			V List Box(
				H List Box(
					combo1 = Combo Box(
						{"", "Normal", "Lognormal"},
						<<setfunction(
							Function( {this, index},
								Match( index,
									1,
										TB << append(
											Try( tba << delete );
											tba = Text Box( "number 1" );
										),
									2,
										TB << append(
											Try( tba << delete );
											tba = Text Box( "number 2" );
										),
									3,
										TB << append(
											Try( tba << delete );
											tba = Text Box( "number 3" );
										),

								)
							)
						)
					)
				)
			)
		)
	)
)

Or you can just have an empty text box and change it's value

nw1 = New Window( "New Test",
	Tab Box(
		TB = Tab Page Box(
			"Analysis",
			V List Box(
				H List Box(
					combo1 = Combo Box(
						{"", "Normal", "Lognormal"},
						<<setfunction(
							Function( {this, index},
								Match( index,
									1, tba << settext( "number 1" ),
									2, tba << settext( "number 2" ),
									3, tba << settext( "number 3" ), 
								)
							)
						)
					)
				),
				tba = Text Box( "" )
			)
		)
	)
)
Jim
Djtjhin
Level IV

Re: Dynamic Display box based on user selection

Thanks Jim! it works