Hide User input box until an option is selected in dropdown

I need to add a hidden user input box until the user selects an option in the dropdown menu cause I need everything to be submitted together into my collection.

  1. Add the user input box normally. Under Properties select either collapse or hide on load.
  2. Add an onChange event to your dropdown. Your code will look something like this:
export function dropdown_onChange() {
	$w("#userInput").show(); //You can chose show or expand
}

Thanks! What do i do though when I want it based on a selection? There are only two to pick from

if ($w("#userInput").value; = true) {
//your code i.e element show/expand
} else {
//your code i.e element show/expand	
}

export function dropdown2_change() {
//Add your code for this event here:
if($(“#dropdown2”).value() = 0){
$w(“#text15”).show(); // Time Interval
$w(“#dropdown3”).show(); //Abbreviation dropdown
$w(“#text14”).show(); //text link to add new abbreviations
$w(“#text13”).show(); //Pill Dose
$w(“#input9”).show(); //Pill Dose user input
$w(“#text12”).show(); //Pill Amount in Cassette
$w(“#input8”).show(); //Pill Amount user input
} else {
$w(“#text15”).show(); // Time Interval
$w(“#dropdown3”).show(); //Abbreviation dropdown
$w(“#text14”).show(); //text link to add new abbreviations
$w(“#text12”).show(); //Pill Amount in Cassette
$w(“#input8”).show(); //Pill Amount user input
}
This is what I put, but I got an error at the if line saying assigning to rvalue. What does this mean?

You should fix it to:

if($w("#dropdown2").value() === 0)

In order to check whether a value equals to zero, you should use the === operator. Click here to learn more about Javascript operators.

Have a good day,
Tal.

thanks that was my issue! now it doesn’t seem to work with the values in the dropdown it always does the default case even when it isn’t

Hi,

Getting the value is not a function, therefore adding parenthesis is not required:

if ($w("#dropdown2").value === 0)

Thanks everyone I solved the issue!