Custom Dropdown Node

I created a custom dropdown node that gets the data from some API and stores it in the dropdown menu.
If i select some of the option it all works fine.But then when i open the node the second time i dont know what i selected previously. The problem bugs me becouse what if i have like 50 objects given from the API and if i select 30 of them . How would i later on know which one i have selected?

And now i made a filter in vanilla js. It works fine but when i try to implement it in node-red it doesnt work.

 function filter() {
        var keyword = $("#node-input-keyword").val();
        var select = $("#node-input-options");
        for (var i = 0; i < select.length; i++) {
          var txt = select.options[i].text;
          if (
            txt.substring(0, keyword.length).toLowerCase() !==
              keyword.toLowerCase() &&
            keyword.trim() !== ""
          ) {
            select.options[i].style.display = "none";
          } else {
            select.options[i].style.display = "list-item";
          }
        }
      }```

this is the code for the filter function. Now i need it to trigger the function on keyup on input.
How do i access that function in script type html.

Without seeing the code you have tried in a node-red node, then we can't really help.

Have you working through the 'creating nodes' guide as was suggested in your previous thread? Node properties : Node-RED

In your oneditprepare you will know what the node is already configured with using this.options. Using that information you'll be able to set the selected state of each option when you reload the list of available options.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.