Hello Everyone,
I simply what a drop downs selection to hide or show an input field. My code almost works, for some reason if i select either of the two drop selections it will hide the input field, and also wont show it if I change the selection . Any help would be greatly appreciated.
export function dropdown3_change() {
if ($w("#dropdown3").value === 1){
$w("#input1").show();
} else ($w("#dropdown3").value ===0)
$w("#input1").hide();
}
Thank you!
Thank you for all of your replies. But unfortunately I am still experiencing the same problem with each solution you have all suggested. For each suggestion if I select either selection from the drop down the input field will disappear and not reappear if i select either selection.
Hi Ben 🖐
You can use either the value or the selected index properties to check whether to show or hide the input field.
let value = $w("#dropdown3").value; let selectedIndex = $w("#dropdown3").value.selectedIndex; // Using the value property if (value === 'Empty') { $w("#input1").hide() } else { $w("#input1").show() } // Using the selected index property if (selectedIndex === 0) { $w("#input1").hide() } else { $w("#input1").show() }
Hope this helps~!
Ahmad
Hello together,
in addition to Anthonys advice (which wants you to convert the type of your values) , i can give you another (not very correct, but working way) to solve your problem.
I call it ---> "the lazy way" 😁
This is your code, try again.... (normaly this should also work).
exportfunction dropdown3_change() {if ($w("#dropdown3").value == 1){ $w("#input1").show(); } else ($w("#dropdown3").value ==0) $w("#input1").hide(); }
But it is not tested, and is also not the very correct way.😁
Hi Ben,
The seemingly numeric value of the dropdown is actually of the type text. Put quotations around the "1" and "0".