top of page

Forum Comments

SOLVED: I need to only show a button when the user input is a match
In Coding with Velo
Nex Im
Jul 11, 2023
I also had the problem although I have been dealing with Velo for months. This can happen. You forgot the brackets at the end of your method (). So it should be correctly $w("#button2").hide(). For example, if you want to hide an element by default and only make it visible by pressing a button, the code would be: $w("#element").hide(); //element is hidden by default $w("#button").onClick(() => { //button makes element visible $w("#element").show(); }); Your other problem I honestly didn't quite understand, maybe you can give more info on that. I am relatively new to learning programming, but try to do roughly what you want: I have a text input field and want that if the text you type matches what I set before (in example it is the word "test"), then the button should appear. Otherwise the button should be hidden. For this I have created an input field named "input1" and next to it a button "button1". First I have to create an onInput event, this is done on the lower right side in the code window (see picture). Now a pre-made code appears to me. I only need this part of it (Do not forget to write in front that the button should be hidden by default): $w("#button1").hide(); export function input1_input(event) { } Now I write an if-condition inside the onInput function (If the value of the input matches this text, then the button should become visible, otherwise hide() again): if ($w("#input1").value === "test") { $w("#button1").show(); } else { $w("#button1").hide(); } The entire code: $w("#button1").hide(); export function input1_input(event) { if ($w("#input1").value === "test") { $w("#button1").show(); } else { $w("#button1").hide(); } } Your source instead of the text is up to you. I hope it helped you a little, good luck!
Content media
1
0

Nex Im

More actions
bottom of page