Simple show/hide text box on button click

I’d like to have a single button toggle on/off two boxes of text (one hides and the other shows).

Here’s my code, I have no clue what I’m doing :sweat_smile::

export function button2_click(event) {

if ($w( “#box19” ).hidden) true ;{
$w( “#box19” ).show();
$w( “#box28” ).hide();


if ($w( “#box19” ).hidden) false ;{
$w( “#box19” ).hide();
$w( “#box28” ).show();

It’s similar to this, but with a single button, and text boxes, not images:
(also how do I even make use of this ^ resource?)

Thanks :grinning:

Johnson, I would not worry about it too much, for we all adhered to the ChaCha-design principle at a certain stage (Cluelessly Horsing Around, Creating Hopeless Applications). But, with a bit of luck, determination and some help, you’ll get past that.
Try this:

export function button2_click(event) {
 if ($w("#box19").hidden) {
 else {

(I didn’t test this, but it should be OK or close).

Read this: to understand.

And another thing: don’t use button_2, box19, etc. If you look at this code again after a year, you will have no clue whatsoever what they mean. It’s better to give them speaking names, like “btnToggle” , “boxWhatever”, and so forth.

Thank you so much! Worked perfectly. And thank you for the tip, that seems like good practice to save me from a lot of headaches in the future. Cheers :slightly_smiling_face: