# Dashboard - How to add OK or Cancel button

**URL:** <https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383>\
**Category:** FAQs\
**Created:** [23 September 2018 15:24 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383 "2018-09-23T15:24:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)\
**Post date:** [23 September 2018 15:24 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/1 "2018-09-23T15:24:59Z")

</div>

OK or Cancel button.

Looking for a method to the following Button action.

When use press the Button. The user will be propmted to select a OK or Cancel button  
IF OK =true then send msg.payload  
IF Cancel . Then do nothing.

I tried the 'show dialog' widget and selected OK/Cancel dialog. But that does not seem set a msg.payload to make a decision .

Surely this has come up before.  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 September 2018 16:17 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/2 "2018-09-23T16:17:11Z")

</div>

you need something to prompt it ... eg

```auto
[{"id":"431f19b3.86d4e8","type":"ui_button","z":"d511095d.512808","name":"","group":"ef85e3b9.8fa4b","order":0,"width":0,"height":0,"passthru":false,"label":"Press","color":"","bgcolor":"","icon":"","payload":"Do you want to continue","payloadType":"str","topic":"","x":140,"y":900,"wires":[["90fa4e9c.a86ab"]]},{"id":"90fa4e9c.a86ab","type":"ui_toast","z":"d511095d.512808","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"OK","cancel":"Cancel","topic":"choice","name":"","x":330,"y":900,"wires":[["be3bc9fa.2aa788"]]},{"id":"be3bc9fa.2aa788","type":"debug","z":"d511095d.512808","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","hideButton":false,"x":530,"y":900,"wires":[]},{"id":"ef85e3b9.8fa4b","type":"ui_group","z":"","name":"Default","tab":"5fcfdb19.86a2b4","disp":true,"width":"6","collapse":false},{"id":"5fcfdb19.86a2b4","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)\
**Post date:** [23 September 2018 17:17 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/3 "2018-09-23T17:17:45Z")

</div>

Thank you dceejay!

Ok, I see that:  
The value in the "Default Action Label "  
and "Secondary Action Label" passed out as the msg.payload

so just triggered off of that.

Thanks again!

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [8 November 2018 14:47 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/4 "2018-11-08T14:47:11Z")

</div>

if i have one text input on dashboard and i want send "yes or not" with show dialog

but i want msg.payload in output no yes or not…….undestend?

---

<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:** [8 November 2018 16:11 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/5 "2018-11-08T16:11:09Z")

</div>

> [@marioarmillei](#):
>
> but i want msg.payload in output no yes or not…….undestend?

Not fully. Do you just mean the display is what you want but you want to change the payload values in the output message to something else? If so then you can use a Change node on the output.

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [8 November 2018 18:06 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/6 "2018-11-08T18:06:24Z")

</div>

where'is my error? ☹  
[{"id":"df1dc23c.d66fd","type":"ui\_button","z":"1dd545bc.459dca","name":"","group":"eb8dd523.be4718","order":0,"width":0,"height":0,"passthru":false,"label":"Press","color":"","bgcolor":"","icon":"","payload":"Do you want to continue","payloadType":"str","topic":"","x":190.00000381469727,"y":249.0000343322754,"wires":[["b703480f.5f8fe8"]]},{"id":"b703480f.5f8fe8","type":"ui\_toast","z":"1dd545bc.459dca","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"OK","cancel":"Cancel","topic":"choice","name":"","x":383.00000762939453,"y":251.00004768371582,"wires":[["a85bc966.a567d8"]]},{"id":"9c2a3d29.94597","type":"ui\_text\_input","z":"1dd545bc.459dca","name":"","label":"","group":"eb8dd523.be4718","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"note","x":191.50003814697266,"y":343.6666965484619,"wires":[["b97ced02.57dc5"]]},{"id":"b97ced02.57dc5","type":"change","z":"1dd545bc.459dca","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.on","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":388.5,"y":342.66668701171875,"wires":[["a85bc966.a567d8"]]},{"id":"a85bc966.a567d8","type":"change","z":"1dd545bc.459dca","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"OK","fromt":"str","to":"payload.on","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":675.5,"y":298.3333435058594,"wires":[[]]},{"id":"eb8dd523.be4718","type":"ui\_group","z":"","name":"Default","tab":"281b30b0.aa591","disp":true,"width":"6","collapse":false},{"id":"281b30b0.aa591","type":"ui\_tab","z":"","name":"Home","icon":"dashboard","order":4}]

---

<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:** [8 November 2018 20:05 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/7 "2018-11-08T20:05:57Z")

</div>

First remember that the messages arriving down the two paths will arrive at different times. When the second message arrives the first one is long gone and the Change node does not remember what was in the previous message. You can use a Join node set to key/value pairs mode to combine the information in the two messages if that is what you are trying to do, then you may be able to use a Change node to do what you want, though it is not clear to me exactly what you want to achieve. Start off by experimenting with the Join node to combine the messages down the two paths.

---

<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:** [9 November 2018 08:28 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/8 "2018-11-09T08:28:38Z")

</div>

Something I am confused about is when is it that you want the ok/cancel dialog to popup?

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [9 November 2018 13:16 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/9 "2018-11-09T13:16:57Z")

</div>

i want write one note and push button to send and another for ok or no  
this message i want sent in one mssql

---

<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:** [9 November 2018 13:38 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/10 "2018-11-09T13:38:48Z")

</div>

OK, I understand. In that case, yes you should use a join node to merge them together into key/value pairs. You don't need to move the payload in the lower branch to a different property, just make sure the two paths have different topics.  
Possibly then easiest to use a Function node to do the rest.

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [10 November 2018 18:46 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/11 "2018-11-10T18:46:56Z")

</div>

sorry i can try.........who can help me?  
i want send one message in one text when i push button

[{"id":"8b09814e.bdae2","type":"tab","label":"DATABASE","disabled":false,"info":""},{"id":"644d9d47.d06f24","type":"ui\_text\_input","z":"8b09814e.bdae2","name":"","label":"","group":"930342e5.d01e","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":397.01952362060547,"y":339.0039281845093,"wires":[["483eeac2.f30734"]]},{"id":"eae0c2a9.948bc","type":"ui\_text\_input","z":"8b09814e.bdae2","name":"","label":"","group":"930342e5.d01e","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":392.01953887939453,"y":405.00392055511475,"wires":[["346dba21.ede096"]]},{"id":"6a66c1b8.865ff","type":"ui\_text\_input","z":"8b09814e.bdae2","name":"","label":"","group":"930342e5.d01e","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":396.0195426940918,"y":471.0039806365967,"wires":[["ade47b7a.a526b8"]]},{"id":"483eeac2.f30734","type":"ui\_button","z":"8b09814e.bdae2","name":"","group":"9ad5468c.2ec478","order":0,"width":0,"height":0,"passthru":false,"label":"button","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":598.0195198059082,"y":343.0039577484131,"wires":[["afafcb0f.6fca08"]]},{"id":"346dba21.ede096","type":"ui\_button","z":"8b09814e.bdae2","name":"","group":"9ad5468c.2ec478","order":0,"width":0,"height":0,"passthru":false,"label":"button","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":601.019552230835,"y":406.00394344329834,"wires":[["afafcb0f.6fca08"]]},{"id":"ade47b7a.a526b8","type":"ui\_button","z":"8b09814e.bdae2","name":"","group":"9ad5468c.2ec478","order":0,"width":0,"height":0,"passthru":false,"label":"button","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":599.0195426940918,"y":470.003981590271,"wires":[["afafcb0f.6fca08"]]},{"id":"fc0face1.8fded","type":"ui\_button","z":"8b09814e.bdae2","name":"clear-button","group":"930342e5.d01e","order":0,"width":0,"height":0,"passthru":false,"label":"Clear","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"","x":166.02349090576172,"y":387.03910636901855,"wires":[["644d9d47.d06f24","eae0c2a9.948bc","6a66c1b8.865ff"]]},{"id":"afafcb0f.6fca08","type":"ui\_text","z":"8b09814e.bdae2","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":834.14453125,"y":396.546875,"wires":[]},{"id":"930342e5.d01e","type":"ui\_group","z":"","name":"Database","tab":"d3375d9d.b1893","disp":true,"width":"6","collapse":false},{"id":"9ad5468c.2ec478","type":"ui\_group","z":"","name":"swich","tab":"d3375d9d.b1893","disp":true,"width":"6","collapse":false},{"id":"d3375d9d.b1893","type":"ui\_tab","z":"","name":"prova","icon":"dashboard","order":1}]

---

<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:** [10 November 2018 19:29 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/12 "2018-11-10T19:29:36Z")

</div>

@marioarmillei please read this post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and edit your previous posts to properly format your flows

---

<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:** [10 November 2018 19:58 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/13 "2018-11-10T19:58:11Z")

</div>

> [@marioarmillei](#):
>
> i want send one message in one text when i push button

Which button? you have four, three that say 'BUTTON' and one that says 'CLEAR'

Why don't you simplify? Remove all but one set and add debugs to the output of each node. Than way you can see what is happening as the flow executes.

---

<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:** [12 November 2018 11:39 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/15 "2018-11-12T11:39:13Z")

</div>

Hi @marioarmillei - once again, I'm asking you to read this post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) about how to properly share flows in this forum.

---

<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:** [12 November 2018 12:23 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/18 "2018-11-12T12:23:27Z")

</div>

Mario,  
you need to read the descriotion of each node you are using and experiment with them.  
Put a debug node on the output of each of your nodes and examine what they contain. Select one of your list items then go look at the debug. What do you fine?

What do you see coming out of the button node?  
What does the node description tell you it will be?

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [12 November 2018 15:21 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/19 "2018-11-12T15:21:27Z")

</div>

ok now i have semplificate.  
i have one dropdown  
select name and i want send name when push button.

```auto
[{"id":"7c4726bc.81cab8","type":"tab","label":"DATABASE","disabled":false,"info":""},{"id":"c9f0e2b2.6112","type":"ui_text","z":"7c4726bc.81cab8","group":"9ad5468c.2ec478","order":3,"width":0,"height":0,"name":"","label":"text","format":"{{msg.op}}","layout":"row-spread","x":710.0196495056152,"y":361.0039119720459,"wires":[]},{"id":"35c0045c.abb6bc","type":"ui_button","z":"7c4726bc.81cab8","name":"","group":"9ad5468c.2ec478","order":2,"width":0,"height":0,"passthru":false,"label":"start message","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":117.01958084106445,"y":266.0039310455322,"wires":[["bfa408e9.9eb048"]]},{"id":"c3f5c4a6.3ea488","type":"ui_dropdown","z":"7c4726bc.81cab8","name":"","label":"","place":"Select option","group":"9ad5468c.2ec478","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"franco","type":"str"},{"label":"","value":"adriano","type":"str"},{"label":"","value":"mario","type":"str"}],"payload":"","topic":"op","x":134.14845275878906,"y":366.7148857116699,"wires":[["bfa408e9.9eb048"]]},{"id":"bfa408e9.9eb048","type":"function","z":"7c4726bc.81cab8","name":"","func":"if (msg.payload =='TRUE') {\n \nHELP ME\n\nreturn msg;","outputs":1,"noerr":5,"x":482.18055725097656,"y":361.01737213134766,"wires":[["c9f0e2b2.6112"]]},{"id":"d5136865.de2d38","type":"ui_button","z":"7c4726bc.81cab8","name":"","group":"9ad5468c.2ec478","order":0,"width":0,"height":0,"passthru":false,"label":"clear","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"str","topic":"","x":569.1944236755371,"y":459.9930992126465,"wires":[["c9f0e2b2.6112"]]},{"id":"9ad5468c.2ec478","type":"ui_group","z":"","name":"swich","tab":"d3375d9d.b1893","disp":true,"width":"6","collapse":false},{"id":"d3375d9d.b1893","type":"ui_tab","z":"","name":"prova","icon":"dashboard","order":1}]

```

---

<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:** [12 November 2018 15:52 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/20 "2018-11-12T15:52:05Z")

</div>

Mario, I'm trying to teach you how to do this. So lets take this one node at a time.Please answer my questions so I know you are trying to learn.

1. if you attach a debug node to a button node and press the button, what shows in the debug?
2. how does that agree/disagree what the info tab for the button node tells you?

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [12 November 2018 17:11 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/21 "2018-11-12T17:11:41Z")

</div>

thanks for helm me... Paul  
I'm learning..node-red  
in the function write  
if msg = true send message of dropdown  
then send null  
is correct?

message of dropdown i must rename? msg.name = msg.payload

and write if (msg.payload =='TRUE')  
msg.payload = msg.name  
return msg;

Where am I wrong?

---

<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:** [12 November 2018 19:09 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/22 "2018-11-12T19:09:51Z")

</div>

What you are doing wrong is not paying attention to the questions I've asked you.

---

<div class="post-metadata">

**Author:** ![marioarmillei](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@marioarmillei](https://discourse.nodered.org/u/marioarmillei)\
**Post date:** [12 November 2018 19:14 UTC](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383/23 "2018-11-12T19:14:48Z")

</div>

[prova](http://i67.tinypic.com/25i2n7m.jpg)  
i have this

[Next page](https://discourse.nodered.org/t/dashboard-how-to-add-ok-or-cancel-button/3383.md?page=2)
