# Problem to save value of a select

**URL:** <https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786>\
**Category:** Developing Nodes\
**Tags:** function-node\
**Created:** [22 January 2024 10:12 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786 "2024-01-22T10:12:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![riri](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@riri](https://discourse.nodered.org/u/riri)\
**Post date:** [22 January 2024 10:12 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/1 "2024-01-22T10:12:24Z")

</div>

Hi everyone

I have a select input with 2 customs value and one string value. When I put the value "type" in the "defaults" and that the click on my node, the node editor is empty while when I put in comment the value "type" it is not anymore but the select does not keep the value in memory while the other fields work very well.  
Thank you in advance for your help

```auto
<script type="text/javascript">
    RED.nodes.registerType('Message',{
        category: 'matrice_svi',
        color: '#A1EEBD',
        defaults: {
            //type: {value:""},
            //static
            condition: {value:""},
            file: {value:""},
            tts:{value:""},
            //complex
            value:{value:""},
            interpretAs:{value:""},
            inputFormat:{value:""},
            format:{value:""},
            fonction:{value:""}
        },
        inputs: 1,
        outputs: 1,
        icon: "icons/icon.svg",
        label: function() {
            return this.name||"Message";
        },
        oneditprepare: function() {
            var static = {
                value: "static",
                label: RED._("node-red:static"),
                hasValue: false
            };
            var complex = {
                value: "complex",
                label: RED._("node-red:complex"),
                hasValue: false
            };
            $("#node-input-type").typedInput({
                type:static,
                types:[static,complex,"str"],
                typeField: "#node-input-typeName"
            })

            $("#node-input-type").on("change", function(e) {
                var val = $("#node-input-type").typedInput('type');
                //static
                console.log(val)
                $(".static").toggle(val === "static");
                $(".complex").toggle(val === "complex");
            });
            $("#node-input-type").change();
        }
    });

</script>

<script type="text/html" data-template-name="Message">

    <div class="form-row">
        <label for="node-input-type"><i class="fa fa-tag"></i>type</label>
        <input type="text" id="node-input-type" placeholder="Chaine de caractère">
        <!--<input type="hidden" id="node-input-typeName">-->
    </div>

    <!-----------------------------Static------------------------------------>
    <div class="static">
        <div class="form-row">
            <label for="node-input-condition"><i class="fa fa-tag"></i>condition</label>
            <input type="text" id="node-input-condition" placeholder="condition">
        </div>
            
        <div class="form-row">
            <label for="node-input-file"><i class="fa fa-tag"></i>file</label>
            <input type="text" id="node-input-file" placeholder="file">
        </div>
        <div class="form-row">
            <label for="node-input-tts"><i class="fa fa-tag"></i>tts</label>
            <input type="text" id="node-input-tts" placeholder="tts">
        </div>
    </div>
    <!------------------------------Complex------------------------------------->
    <div class="complex">
        <div class="form-row">
            <label for="node-input-interpretAs"><i class="fa fa-tag"></i>interpretAs</label>
            <input type="text" id="node-input-interpretAs" placeholder="interpretAs">
        </div>
        <div class="form-row">
            <label for="node-input-value"><i class="fa fa-tag"></i>value</label>
            <input type="text" id="node-input-value" placeholder="value">
        </div>
        <div class="form-row" >
            <label for="node-input-inputFormat"><i class="fa fa-tag"></i>inputFormat</label>
            <input type="text" id="node-input-inputFormat" placeholder="inputFormat">
        </div>

        <div class="form-row">
            <label for="node-input-format"><i class="fa fa-tag"></i>format</label>
            <input type="text" id="node-input-format" placeholder="format">
        </div>
        <div class="form-row">
            <label for="node-input-fonction"><i class="fa fa-tag"></i>fonction</label>
            <input type="text" id="node-input-fonction" placeholder="fonction">
        </div>
    </div>

</script>

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 January 2024 10:22 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/2 "2024-01-22T10:22:25Z")

</div>

> [@riri](#):
>
> ```auto
> //type: {value:""},
> 
> ```

if you look at the export of any node-red flow, you will see EVERY node has a `type` property. It is what tells the core the type of node to instanciate.

So, basically, dont use `type` as one of your properties since it will be superceded / overwritten by Node-RED core code.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 January 2024 10:26 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/3 "2024-01-22T10:26:58Z")

</div>

> [@riri](#):
>
> ` RED.nodes.registerType('Message',{}`)

Furthermore - i **strongly** recommend not to use vague node type names.

using `message` will undoubtedly cause issues if not now, later for users who happen to install other nodes that will use that name.

Try to make them unique across the node-red platform i.e: `riri-message`

---

<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:** [22 January 2024 13:36 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/4 "2024-01-22T13:36:51Z")

</div>

> [@riri](#):
>
> `RED.nodes.registerType('Message'`

Please do not use generic names for your node, you are certain to cause name clashes for people who want to use them.

(Sorry Marcus, should have read down the thread first, I didn't see your reply).

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [22 January 2024 13:42 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/5 "2024-01-22T13:42:32Z")

</div>

Hey! We’re all friends here 😃

---

<div class="post-metadata">

**Author:** ![riri](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@riri](https://discourse.nodered.org/u/riri)\
**Post date:** [23 January 2024 10:10 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/6 "2024-01-23T10:10:38Z")

</div>

I renamed the node with another name and after forgetting 2-3 elements it works, thanks for your help

---

<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:** [6 February 2024 10:11 UTC](https://discourse.nodered.org/t/problem-to-save-value-of-a-select/84786/7 "2024-02-06T10:11:34Z")

</div>

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