# Storing msg.payload in select tag

**URL:** <https://discourse.nodered.org/t/storing-msg-payload-in-select-tag/44097>\
**Category:** Developing Nodes\
**Created:** [13 April 2021 11:57 UTC](https://discourse.nodered.org/t/storing-msg-payload-in-select-tag/44097 "2021-04-13T11:57:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jake123](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jake123](https://discourse.nodered.org/u/jake123)\
**Post date:** [13 April 2021 11:57 UTC](https://discourse.nodered.org/t/storing-msg-payload-in-select-tag/44097/1 "2021-04-13T11:57:10Z")

</div>

This is my custom websocket node. As you see the msg it outputs is an object  
`{ name: datapointname, value: data }`  
Could i somehow create Select tag that has options based on how many msg.payload it recives. Options text would be the `datapointname` property and the value would be `data` property

```auto
module.exports = function(RED) {
    function wsListenerNode(config) {
        RED.nodes.createNode(this,config); 
        this.path = config.path;
        var node = this;
        node.on('input', function(msg) {  
            const WebSocket = require ("ws") // Require Websocket
            let path = node.path;
            let ws = new WebSocket(path); //Connect to the WebSocket //ws://192.168.1.41:22080/webevent/ 
        ws.onopen = (e) => {
              console.log(e);
                setTimeout(function () {
                  ws.send(
                    msg.payload
                  );
                }, 1000);
            };
        ws.onmessage = (e) => {
              msg.payload = e.data;
              var stripped = msg.payload.trim();
              var values = stripped.split("\n");
      
              var datapointname = values[0].substring(37, values[0].length - 14);
              data = Number(values[1]);
              msg.payload = {name:datapointname,value: data}
              node.send(msg)
                };
        });
    }
    RED.nodes.registerType("websocketListener",wsListenerNode);
}

```

I want to display the result when i open the node

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 April 2021 13:46 UTC](https://discourse.nodered.org/t/storing-msg-payload-in-select-tag/44097/2 "2021-04-13T13:46:17Z")

</div>

I think you will find this question has been answered in the last few days. Yes, you can create a dropdown using a select tag. You need to use the `oneditprepare` function to set it up and manage it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 June 2021 13:47 UTC](https://discourse.nodered.org/t/storing-msg-payload-in-select-tag/44097/3 "2021-06-12T13:47:04Z")

</div>

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