# Beginner needs help

**URL:** <https://discourse.nodered.org/t/beginner-needs-help/1775>\
**Category:** General\
**Created:** [24 July 2018 08:30 UTC](https://discourse.nodered.org/t/beginner-needs-help/1775 "2018-07-24T08:30:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![leNiac](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leniac/32/1331_2.png) [@leNiac](https://discourse.nodered.org/u/leNiac)\
**Post date:** [24 July 2018 08:30 UTC](https://discourse.nodered.org/t/beginner-needs-help/1775/1 "2018-07-24T08:30:11Z")

</div>

Hello, i'm just starting on nodered and I have a problem. I'm creating a custom node but can't get the js file to work. In my html file i have this :

```
<div class="form-row">
    <input type="text" id="node-input-finalMsg" name="Message Final"/>
</div>

```

And in my js file :

```
module.exports = function (RED) {
    function AffichageNode(config) {
        RED.nodes.createNode(this, config);
        var node = this;
        this.finalMsg = config.finalMsg;
        this.on('input', function () {
            console.log(node.finalMsg)
        });
    }
    RED.nodes.registerType("Affichage", AffichageNode);
}

```

But if i run this code I get an "undefined" in the console. can someone help?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [24 July 2018 08:49 UTC](https://discourse.nodered.org/t/beginner-needs-help/1775/2 "2018-07-24T08:49:39Z")

</div>

Is that your entire html file?

Its missing the `<script>` parts ( see [https://nodered.org/docs/creating-nodes/node-html](https://nodered.org/docs/creating-nodes/node-html))

As you want to take something from the configuration part you should also look at the "Configuration Nodes" page. [https://nodered.org/docs/creating-nodes/config-nodes](https://nodered.org/docs/creating-nodes/config-nodes)

---

<div class="post-metadata">

**Author:** ![leNiac](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leniac/32/1331_2.png) [@leNiac](https://discourse.nodered.org/u/leNiac)\
**Post date:** [24 July 2018 08:55 UTC](https://discourse.nodered.org/t/beginner-needs-help/1775/3 "2018-07-24T08:55:07Z")

</div>

this is a sample, not the entire html, here my html file complete

```
<script type="text/javascript">
//stuff
    RED.nodes.registerType('Affichage', {
        category: 'Gertrude',
        color: '#91db85',
        defaults: {
            name: { value: "" }
        },
        inputs: 1,
        outputs: 1,
        icon: "affichage.png",
        label: function () {
            return this.name || "Affichage";
        },     
        oneditprepare: function() {
            //stuff
        },
        oneditcancel: function(){
           //stuff
        },
        oneditsave: function(){
            //stuff                   
        }
    });
</script>

<script type="text/x-red" data-template-name="Affichage">
//html here
 <div class="form-row">
    <input type="text" id="node-input-finalMsg" name="Message Final"/>
</div>
</script>

<script type="text/x-red" data-help-name="Affichage">
</script>
```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 July 2018 08:59 UTC](https://discourse.nodered.org/t/beginner-needs-help/1775/4 "2018-07-24T08:59:41Z")

</div>

> [@leNiac](#):
>
> `defaults: { name: { value: "" } },`

You need to include `finalMsg` in the `defaults` object so the editor knows this is a property to save to the node configuration.

---

<div class="post-metadata">

**Author:** ![leNiac](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leniac/32/1331_2.png) [@leNiac](https://discourse.nodered.org/u/leNiac)\
**Post date:** [24 July 2018 09:08 UTC](https://discourse.nodered.org/t/beginner-needs-help/1775/5 "2018-07-24T09:08:20Z")

</div>

```
RED.nodes.registerType('Affichage', {
        category: 'Gertrude',
        color: '#91db85',
        defaults: {
            finalMsg: { value: ""},
            name: { value: "" }
        },
        inputs: 1,
        outputs: 1,
        icon: "affichage.png",
        label: function () {
            return this.name || "Affichage";
        },

```

This is what I did and I still get the undefined
