# A simple question about how to call "Select from a list of options" in a js file

**URL:** <https://discourse.nodered.org/t/a-simple-question-about-how-to-call-select-from-a-list-of-options-in-a-js-file/79281>\
**Category:** General\
**Created:** [18 June 2023 13:46 UTC](https://discourse.nodered.org/t/a-simple-question-about-how-to-call-select-from-a-list-of-options-in-a-js-file/79281 "2023-06-18T13:46:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angin](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Angin](https://discourse.nodered.org/u/Angin)\
**Post date:** [18 June 2023 13:46 UTC](https://discourse.nodered.org/t/a-simple-question-about-how-to-call-select-from-a-list-of-options-in-a-js-file/79281/1 "2023-06-18T13:46:03Z")

</div>

How to call the select from a list of options in a js file?  
This is the HTML file:

```auto
<script type="text/javascript">
    RED.nodes.registerType('testnode', {
        category: 'output',
        color: '#006738',
        defaults: {
            name: {value: ""},
            test: {value: ""},
        },
        inputs: 1,
        outputs: 1,
        paletteLabel: "testnode",
        label: function () {
            return (this.name || 'testnode');
        },
        oneditprepare: function () {
            $('#node-input-test').typedInput({
                types: [ 'test',
                value: "test",
                options:[
                {value: "01", label: "Options 1"},
                {value: "02", label: "Options 2"},
                {value: "03", label: "Options 2"},
                {value: "04", label: "Options 4"},
                ]
            });
        }
    });
</script>

```

This is the JS file:

```auto
module.exports = function (RED) {
    function testnodeNode(config) {
        RED.nodes.createNode(this, config);

        let node = this;
        let test = config.test;
        
        node.on("input", function (msg) {
            let str = msg.payload.toString("hex");
            
            let sum = parseInt("xxxx", 16) + parseInt(test, 16);

            if(str == "xxxx" + test + sum.toString(16){
                msg.payload = "test" + test;

                node.send(msg);            
               });
            }
        });
    }
    RED.nodes.registerType("testnode", testnodeNode);
}

```

Which needs to use the msg.payload from the previous node and call the selected option value for comparison and output the final result.  
The options called in the above js file are invalid.  
How can the selected option value be called in the JS file?  
Any help would be greatly appreciated!

---

<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:** [17 August 2023 13:46 UTC](https://discourse.nodered.org/t/a-simple-question-about-how-to-call-select-from-a-list-of-options-in-a-js-file/79281/2 "2023-08-17T13:46:07Z")

</div>

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