Choose Language Hide Translation Bar
Highlighted
samir
Level IV

Issues to hide a text edit box in a radio box

Hi,

I am trying to use a radio box that should hide/show a text edit box, but it does not work (see code attached).

Basically Choice 1 should show the text edit box, and Choice 2  should hide it.

I see at least 2 abnormal behavior:

1. if I clic several times on Choice 2, the text edit box is hiden, then shown, then hiden, then shown,... Although, it should stay hidden

2. Clicking on CHoice 1 does not always show the text edit box: it depends on the state of the text edit box before clicking...

I guess i am missing something fundamental

MyWindow = New Window( "Test...",
Panel Box( "Info",
		rb = Radio Box(
			{"Choice 1", "Choice 2"},
			<<Set Function(
				Function({self}, 
					match(self << Get Selected,
						"Choice 1", y << set text("Choice 1 is validated"); GB << show ();, 
						"Choice 2", y << set text("Choice 2 is validated"); GB << hide (); //New Window( "HTRB Data Collection...",),
					)	
				)
			), 
			
		), 
		y = text  box("If choice 2 , this box should be hidden !!!!"),
		GB = text edit box("if you clic twice on Choice 2, this is not hidden !!!!"),
		//GB << hide (),

	),
	
	);
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
pmroz
Super User

Re: Issues to hide a text edit box in a radio box

Not sure why your code wasn't working.  Maybe because you didn't supply an argument to hide?  In any event you can include the code inside MyWindow thusly:

NamesDefaultToHere(1);

MyWindow = 
New Window( "Test...",
	Panel Box( "Info", 
		rb = Radio Box({"Choice 1", "Choice 2"},
			choice = rb << getSelected;
			if (choice == "Choice 1", teb << hide(0),
				choice == "Choice 2", teb << hide(1)
			);
		),
		teb = text edit box("Some text to edit")
	)
);

View solution in original post

3 REPLIES 3
Highlighted
ian_jmp
Staff

Re: Issues to hide a text edit box in a radio box

Here's one way:

NamesDefaultToHere(1);

MyWindow = 
New Window( "Test...",
	Panel Box( "Info", 
		rb = Radio Box({"Choice 1", "Choice 2"}),
		teb = text edit box("Some text to edit")
		)
	);

rb << setScript(
		choice = rb << getSelected;
		if(
			choice == "Choice 1", teb << hide(0),
			choice == "Choice 2", teb << hide(1)
			)
		);
Highlighted
samir
Level IV

Re: Issues to hide a text edit box in a radio box

Hi Jan,

Great it works !!!!

I m trying to understand...Is my code not working because I try to execute hide and show inside MyWindow ??

Highlighted
pmroz
Super User

Re: Issues to hide a text edit box in a radio box

Not sure why your code wasn't working.  Maybe because you didn't supply an argument to hide?  In any event you can include the code inside MyWindow thusly:

NamesDefaultToHere(1);

MyWindow = 
New Window( "Test...",
	Panel Box( "Info", 
		rb = Radio Box({"Choice 1", "Choice 2"},
			choice = rb << getSelected;
			if (choice == "Choice 1", teb << hide(0),
				choice == "Choice 2", teb << hide(1)
			);
		),
		teb = text edit box("Some text to edit")
	)
);

View solution in original post

Article Labels

    There are no labels assigned to this post.