How to populate a text, based on user selection in the dropdown.

Dear all,

I would like to populate a message based on the selection of the user in the dropdown list but no success up to now. It seems so simple but for some reason not working. Here is the code I am using.

$w("#myElement").onCustomValidation( (value, reject) => {
2  if(value === "test") {
3    reject("test is invalid");
4  }
5} );

What could be the reason here?

The onCustomValidation() function is for implementation of custom validation of user input.

For your use, you will need to use the Dropdown onChange() function. When the user selects an option from the Dropdown, the text message can then be set.

Thank you. Can you help me with the coding? I am not able to that.

Do not expect people to code for you, you already have the answer and the links, that’s all the help you need, just read the examples in the links and you should be able to do it by yourself.

If you couldn’t pull this off after reading the links, you can then hire a developer to do it for you.

@ahmadnasriya is it against forum rules to ask for coding help?

no, asking for help with your code or ask someone to do it for you is not against any rules, just don’t expect people to do your work and give ready to use solutions for free, once you share your code and explain what’s not working, the community will be more than happy to help.

@ahmadnasriya Thanks!

@aisikalp
I support Ahmad’s opinion, but let’s not be too strict because you seem like a newbie to JS programming, who realy need some help, regarding the description of your issue and compared it with your provided code → it’s clear that you do not know what you are doing exactly.

This is what you want to achieve…

I would like to populate a message based on the selection of the user in the dropdown list but no success up to now. It seems so simple but for some reason not working. Here is the code I am using.
You want to create a → MESSAGE / STRING ← with the help of selected VALUE from a → DROPDOWN

So let’s do a very simple example!

Your SETUP would be:
1x Dropdown
1x Text-Box
+the following code…

$w.onReady(()=>{
    $w("#myDropDownIDhere").onChange(()=>{
        let mySelectedValue = $w("#myDropDownIDhere").value
        start_someAction(mySelectedValue);
    });
})

function start_someAction(mySelectedValue) {
    //put in here your code --> what should happen after DropDown was changed ???
    //For example....
    $w('#myTextBoxIDhere).text="This is my selected VALUE --> "+mySelectedValue+" from my dropdown."
}

All you need to be able to code → you can find in the Velo-API-Docs, like already shown/mentioned by Yisrael… Dropdown onChange()

Take a look onto the CONSOLE and see which results you get.

2 Likes

@russian-dima It worked! Thanks a lot.

1 Like