How to hide/show element based on what choice is selected in radio button?

Hi! I’m trying to figure out how to hide element specifically image when i select other choice. I was searching on forum and I found similar problems but no one solved mine.

I combined with code and it looks like it should work, but it doesn’t.

if ( $w ( “#radioGroup1” ). value == “Uczeń” ) {
$w ( “#vectorImage2” ). hide ()
}
if ( $w ( “#radioGroup1” ). value == “Nauczyciel” ) {
$w ( “#vectorImage2” ). show ()
}

Hi there :wave:t2: I assume this code is in the onReady function for the page?
If this is the case, you should try adding an onChange event to the radio group, to successfully trigger the code. Good luck!

Thank you so much, it works, but it never shows again. I want it to be shown on first selection and hidden on second. Any ideas?

@biznesszymonczaja Could you share your new code?

@lmeyer of course.

export function radioGroup1_change ( event ) {
$w ( “#vectorImageSecond” ). hide ()
$w ( “#vectorImage2” ). hide ()

@biznesszymonczaja its because every change hides the elements. How do you intend to make them appear again?

@biznesszymonczaja You will need to work with an if/else statement to get your desired functionality. The “best answer” to this post should give you the proper format for your code.

That’s it! Thank you again. Works literally perfect now.