Subscribe Bookmark RSS Feed

Is it possible to update Text Box based on Combo Box Selection

WendyLou315

Occasional Contributor

Joined:

Apr 13, 2017

Hello!  I am new to JSL and trying to develop a tool for an engineering group.  What we'd like to do is to pull data from a table and display the results of one record based on a selection of items available.  I have developed a super simple version and cannot get it to work.  Is it even possible to update a Text Box in a window based on a selection made in a Combo Box.  << Reshow is not doing what I had hoped it would.  If this isn't possible, are there any other options? 

 

Here is the code I'm trying to learn from:

update = expr(cb << Get Selected;
	tb2 << reshow); //refresh code

TestArray = {"This", "That", "The Other"}; //my list of 'stuff'

nw = New Window("Sample", << Modal,
	vlb = V List Box(
		cb = Combo Box(TestArray //my list of 'stuff' in a combo box
		),
		hlb = H List Box (
			tb1 = Text Box (" You selected: "),  //label
				tb2 = Text Box (cb << Get Selected;), //return the current item
				update; //call to refresh the text box (but it doesn't)
			//I have named all display boxes in hopes that <<reshow of one of them 
			//would be the ticket.  Nothing worked the way I wanted.
		)
	)
)
1 ACCEPTED SOLUTION

Accepted Solutions
M_Anderson

Staff

Joined:

Nov 21, 2014

Solution

Try this:

 

TestArray = {"This", "That", "The Other"}; //my list of 'stuff'
string = "You Selected:  This";

nw = New Window( "Sample",
	<<Modal,
	vlb = V List Box(
		cb = Combo Box(
			TestArray,
			choice = cb << Get Selected;
			show(string);
			string = "You Selected:  " || choice;
			tb1 << Set Text( string );
		),
tb1 = Text Box(string)
	)
);

best,

 

M

4 REPLIES
M_Anderson

Staff

Joined:

Nov 21, 2014

Solution

Try this:

 

TestArray = {"This", "That", "The Other"}; //my list of 'stuff'
string = "You Selected:  This";

nw = New Window( "Sample",
	<<Modal,
	vlb = V List Box(
		cb = Combo Box(
			TestArray,
			choice = cb << Get Selected;
			show(string);
			string = "You Selected:  " || choice;
			tb1 << Set Text( string );
		),
tb1 = Text Box(string)
	)
);

best,

 

M

txnelson

Super User

Joined:

Jun 22, 2012

I will add to Mark's comments that you can see exellent examples for all of the elements available to Text Edit Boxes and all other display object in the Scripting Index.  It makes working with JSL object much easier

     Help==>Scripting Index==>Text Edit Box

Jim
WendyLou315

Occasional Contributor

Joined:

Apr 13, 2017

Thanks, txnelson! I will certainly do that and keep referring to the Scripting Index as I continue to learn JSL.
WendyLou315

Occasional Contributor

Joined:

Apr 13, 2017

Thank you SO very much M_Anderson. That worked beautifully. Now to fit it to my exact needs. I can't begin to express how thrilled I am. I'm truly looking forward to learning more about JSL!