All,
I found this post and example very relevant to my needs. https://community.jmp.com/t5/Discussions/Creating-drop-down-menu-for-interactive-user-input/td-p/179.... However, as I try to implement/execute the code piece provided here, I don't see what I expected to happen. I think it is a typo, provided is my edited - working code.
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
/* Extract a list of unique ages */
Summarize( a = By( :age ) );
Insert Into( a, "<Select Age>", 1 );
/* Create a modal dialog */
New Window( "Example",
<<Modal,
H List Box(
/* Upon selecting an age, populate the second ComboBox with corresponding names */
Panel Box( "Select an Age:",
cb1 = Combo Box(
a,
<<SetFunction(
Function( {this},
selection = this << Get Selected();
r = dt << Get Rows Where( :age == Num( selection ) );
ageNames = :name[r]; ///////////////////////////////// EDIT - Needs to be :name[r] and not :name
Insert Into( ageNames, "<Select Name>", 1 );
cb2 << Set Items( ageNames );
)
)
)
),
/* Print the selected values from both ComboBoxes in the log */
Panel Box( "Select a Name:",
cb2 = Combo Box(
{"<Select Name>"},
<<SetFunction(
Function( {this},
that=this<< Get Selected();
Print( selection, that )
)
)
)
)
)
);
sel=num(selection)
Looking at the code and reading through it, I was hoping once the user selects an age in the first Combo Box, the second Combo Box should be populated with the names of people with that age. However, I don't see that happening here with the original code. This above code fixes it.
Is this the best way to handle this - Or are there other options ?
Best
Uday