Dropdown option for "Other" as a Text Box

I have a form where the user can select from a drop down or select other and get a text box field to type his response. This is how i did it, but is there a better way? We are using a dropdown and a collapse field right under it.

function checkEventLocation () {
if ( $w ( ‘#eventLocation’ ). value === ‘Other’ ) {
$w ( ‘#eventLocation’ ). collapse ()
$w ( ‘#otherLocation’ ). expand ()
eventLocation = $w ( ‘#otherLocation’ ). value
} else if ( $w ( ‘#eventLocation’ ). value === undefined ) {
$w ( ‘#otherLocation’ ). collapse ()
$w ( ‘#eventLocation’ ). expand ()
eventLocation = $w ( ‘#eventLocation’ ). value
} else {
$w ( ‘#otherLocation’ ). collapse ()
$w ( ‘#eventLocation’ ). expand ()
eventLocation = $w ( ‘#eventLocation’ ). value
}

}

function goBacktoSelect () {
if ( $w ( ‘#otherLocation’ ). value === ‘’ ) {
$w ( ‘#eventLocation’ ). expand ()
$w ( ‘#otherLocation’ ). collapse ()
console . log ( ‘select event name again’ )
} else {
eventLocation = $w ( ‘#otherLocation’ ). value
}
}
export function eventLocation_change ( event ) {
checkEventLocation ()

}

export function btnResetForm_click ( event , $w ) {
resetForm ();
}
console . log ( $w ( ‘#eventLocation’ ). value )

function resetForm () {
const inputList = $w ( ‘TextInput’ );
const dropdown = $w ( ‘Dropdown’ );

inputList . forEach ( element  => { 
    element . value  =  '' ; 

});
dropdown . forEach ( element => {
element . value = ‘’ ;
});
$w ( ‘#eventLocation’ ). expand ()
$w ( ‘#otherLocation’ ). collapse ()

}

export function otherLocation_change ( event ) {
goBacktoSelect ()

}