# Clear Dashboard Text Input and Set Drop Down, Switch, Slider, Numeric and Date Picker to Default with Button

**URL:** <https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626>\
**Category:** Dashboard\
**Created:** [17 July 2018 07:11 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626 "2018-07-17T07:11:55Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [17 July 2018 07:11 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/1 "2018-07-17T07:11:55Z")

</div>

Hi,

I'm expecting a dashboard button to clear input text and set drop down, switch, slider, numeric and date picker to default on click.

I know there is Cancel button on form node by default, but I'm not using form node at this moment as I need drop down. The drop down element is not available on form node.

Thanks for helping.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2018 07:18 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/2 "2018-07-17T07:18:37Z")

</div>

So what have you tried so far? I'd try having an inject button send something to each of the ui nodes you want to reset and figure out how to reset each one (read the node info for each). once you get that to work, you could have your reset button link to the flow that resets the ui codes you are using.

---

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [17 July 2018 09:18 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/3 "2018-07-17T09:18:44Z")

</div>

Hi,

I added change node and set the msg.payload to string (null) after the button. Then I connected the change node to the dashboard inputs.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 July 2018 09:38 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/4 "2018-07-17T09:38:28Z")

</div>

Did that work?  
As @zenofmud suggested it might be simpler initially to connect inject nodes to each one then you can experiment with different values till you find out what you need to inject for each type of field.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2018 16:35 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/5 "2018-07-17T16:35:42Z")

</div>

Did you look at the info tab for each of the ui-nodes to see what is needed to reset them?

---

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [18 July 2018 02:35 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/6 "2018-07-18T02:35:12Z")

</div>

I tried the following:

```auto
[{"id":"8f1e9a5e.0b27d8","type":"ui_dropdown","z":"85a0b8d9.6add58","name":"","label":"","place":"Select option","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"options":[{"label":"Amy","value":1,"type":"num"},{"label":"Bob","value":2,"type":"num"}],"payload":"","topic":"","x":460,"y":60,"wires":[[]]},{"id":"fd1982c3.b54f1","type":"ui_switch","z":"85a0b8d9.6add58","name":"","label":"switch","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":450,"y":120,"wires":[[]]},{"id":"d3af1ed2.88646","type":"ui_slider","z":"85a0b8d9.6add58","name":"","label":"slider","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"topic":"","min":0,"max":10,"step":1,"x":450,"y":180,"wires":[[]]},{"id":"f96b24d.6b9b9d8","type":"ui_numeric","z":"85a0b8d9.6add58","name":"","label":"numeric","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"topic":"","format":"{{value}}","min":0,"max":10,"step":1,"x":460,"y":240,"wires":[[]]},{"id":"c9945030.42ae2","type":"ui_text_input","z":"85a0b8d9.6add58","name":"","label":"","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"","x":460,"y":300,"wires":[[]]},{"id":"9759df3e.f4c2f","type":"ui_date_picker","z":"85a0b8d9.6add58","name":"","label":"date","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"topic":"","x":450,"y":360,"wires":[[]]},{"id":"212555b2.082b3a","type":"ui_colour_picker","z":"85a0b8d9.6add58","name":"","label":"","group":"b44d8a41.4ba8a8","format":"hex","outformat":"string","showSwatch":true,"showPicker":false,"showValue":false,"showHue":false,"showAlpha":false,"showLightness":true,"dynOutput":"false","order":0,"width":0,"height":0,"passthru":false,"topic":"","x":470,"y":420,"wires":[[]]},{"id":"60b44173.def3c","type":"change","z":"85a0b8d9.6add58","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":90,"y":240,"wires":[["11a3bb54.53c8a5"]]},{"id":"11a3bb54.53c8a5","type":"ui_button","z":"85a0b8d9.6add58","name":"clear-button","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"label":"Clear","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"","x":250,"y":240,"wires":[["8f1e9a5e.0b27d8","fd1982c3.b54f1","d3af1ed2.88646","f96b24d.6b9b9d8","c9945030.42ae2","9759df3e.f4c2f","212555b2.082b3a"]]},{"id":"b44d8a41.4ba8a8","type":"ui_group","z":"","name":"Group 1","tab":"491c9b78.645584","order":1,"disp":false,"width":"6","collapse":false},{"id":"491c9b78.645584","type":"ui_tab","z":"","name":"I4Inari - Clear Inputs","icon":"dashboard","order":4}]

```

It seems that text input, slider, numeric, date and color changed to default once I click the Clear button. But, the switch never change to off state back. How to make that the switch back to off once I click on the Clear button? The following is the information of the switch:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fc90b74887c2d5a17c1402b50409e7e2ee04b35b.png)

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [18 July 2018 03:45 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/7 "2018-07-18T03:45:48Z")

</div>

Can you use a `ui_button` to do that same thing, instead of a switch?

---

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [18 July 2018 05:42 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/8 "2018-07-18T05:42:10Z")

</div>

Yes, I can use a button. I think it's better idea.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 July 2018 09:54 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/9 "2018-07-18T09:54:58Z")

</div>

> [@rishanaziz](#):
>
> How to make that the switch back to off once I click on the Clear button?

ummm how about sending it an 'off'?

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [18 July 2018 12:41 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/10 "2018-07-18T12:41:42Z")

</div>

> [@rishanaziz](#):
>
> How to make that the switch back to off once I click on the Clear button?

Inject msg.payload with boolean = false. It worked for me.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 July 2018 20:24 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/11 "2018-07-18T20:24:23Z")

</div>

> [@rishanaziz](#):
>
> How to make that the switch back to off once I click on the Clear button

To set it on or off you have to send it _exactly_ the value that it is configured to send. So since yours is set to send boolean true or false that is what you have to send it to set it on of off via a message.

---

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [19 July 2018 01:38 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/12 "2018-07-19T01:38:48Z")

</div>

Hi Andrei,

Thank you very much. It worked for me as well. Appreciate your help.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2018 08:06 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/13 "2018-07-19T08:06:06Z")

</div>

> [@rishanaziz](#):
>
> Thank you very much. It worked for me as well

Do you understand _why_ sending false worked?

---

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [19 July 2018 09:27 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/14 "2018-07-19T09:27:03Z")

</div>

Hi Colin,

The on and off payload on switch node had been set as true and false. When send false, it turns off the switch. This is what I understand. Maybe you have other reasons that I didn't notice.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2018 12:43 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/15 "2018-07-19T12:43:41Z")

</div>

I was just checking, since you did not respond to my post saying exactly that.

---

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [23 July 2018 00:08 UTC](https://discourse.nodered.org/t/clear-dashboard-text-input-and-set-drop-down-switch-slider-numeric-and-date-picker-to-default-with-button/1626/16 "2018-07-23T00:08:28Z")

</div>

I see. I'm sorry, Colin. Thank you very much for helping.
