# Store value in custom node HTML

**URL:** https://discourse.nodered.org/t/store-value-in-custom-node-html/70991
**Category:** Developing Nodes
**Created:** [21 November 2022 16:11 UTC](https://discourse.nodered.org/t/store-value-in-custom-node-html/70991 "2022-11-21T16:11:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ItsDaveTheWave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/itsdavethewave/32/65618_2.png) [@ItsDaveTheWave](https://discourse.nodered.org/u/ItsDaveTheWave)
#### Post date: [21 November 2022 16:11 UTC](https://discourse.nodered.org/t/store-value-in-custom-node-html/70991/1 "2022-11-21T16:11:49Z")

</div>

I would like to store a certain dynamic value for it to be used in the HTML of my custom node.

For example, when using a spinner input we can create a function that is executed whenever the value of the spinner changes, like in this example which checks the value of the spinner is not below 1.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e3e75a847958c521b7438c0e5f26b791762a68f.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/7171d1630f9e70a175d22f30d7a45b8d43862874.png)

What Im trying to achieve: when an invalid value is inserted into the spinner I want the value to be replaced by the latest valid value. For example: First introduce valid value 5, then introduce invalid value "hi there", finally value is changed back to 5 since it is the latest valid value.

To accomplish this I was trying to store the previous valid value inside the defaults.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/11524e1fe4fe61bb82d38de8755221ea70efc36b.png)

However, then I am unable to properly read those values with a console.log(), Ive tried the following:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0adc4e0d82cdbd3d447cb20a14631956c5bcf29.png)

I am unsure if a default has to necessarily bounded to an input or if it can be used to store data like Im trying to.  
I also tried creating a hidden input with id 'node-input-previousOutputs' and using typedInput('hide') but I couldnt get that to work either.

Is my approach wrong? Is there a better way to do this?  
Thanks in advance

---

<div class="post-metadata">

### Author: ![ItsDaveTheWave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/itsdavethewave/32/65618_2.png) [@ItsDaveTheWave](https://discourse.nodered.org/u/ItsDaveTheWave)
#### Post date: [21 November 2022 17:02 UTC](https://discourse.nodered.org/t/store-value-in-custom-node-html/70991/2 "2022-11-21T17:02:55Z")

</div>

It was much simpler than I thought, I was able to solve it with this, no hidden input.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/508684a8dd1e34f70731de070d015d7058639e02.png)

Note that the '24' in the previousOutputs value does not do anything, it is the node.previousOutputs = node.outputs that matters.  
Sorry for the trouble, hope this can help somebody in the future 😃

---

<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: [5 December 2022 17:03 UTC](https://discourse.nodered.org/t/store-value-in-custom-node-html/70991/3 "2022-12-05T17:03:03Z")

</div>

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