# Dropdown node cuts a "0" at the end

**URL:** https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454
**Category:** General
**Created:** [10 May 2021 21:07 UTC](https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454 "2021-05-10T21:07:52Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)
#### Post date: [17 May 2021 19:16 UTC](https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454/21 "2021-05-17T19:16:32Z")

</div>

```auto
[{"id":"8db0322a.4cc4d","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"f2042e3d.90c87","type":"ui_dropdown","z":"8db0322a.4cc4d","name":"","label":"selection","tooltip":"","place":"Select option","group":"807b5c7.909b2a","order":12,"width":0,"height":0,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"topic","topicType":"msg","x":680,"y":240,"wires":[["29a91919.2b6b46"]]},{"id":"9bd7e49e.1dbab8","type":"function","z":"8db0322a.4cc4d","name":"transform data to correct format","func":"//as per info panel, the data needs to be formatted\n//as [\"Choice 1\", \"Choice 2\", {\"Choice 3\":\"3\"}]\n//and sent in msg.options.\nmsg.options = [];//create empty array\nfor(let i = 0; i < msg.payload.length; i++){\n let row = (msg.payload[i]); //get the row\n let opt = {};//make new opt object\n opt[row[0]] = (row[1] +=\"$\"); //add a propery to object called row[0] & set its value to row[1]\n //the +=\"$\" is added to force every row to a string in the dropdown after \n msg.options.push(opt);//add the opt to array \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":240,"wires":[["f2042e3d.90c87"]]},{"id":"510f0df8.dafec4","type":"inject","z":"8db0322a.4cc4d","name":"Fake DB Result","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"[[\"123-134M\",\"123-134M\"],[\"44750\",\"44750\"],[\"33640.20\",\"33640.20\"],[\"35789.30\",\"35789.30\"],[\"23456.10\",\"23456.10\"]]","payloadType":"json","x":120,"y":240,"wires":[["9bd7e49e.1dbab8"]]},{"id":"d4687052.28546","type":"ui_text","z":"8db0322a.4cc4d","group":"807b5c7.909b2a","order":1,"width":0,"height":0,"name":"","label":"articel","format":"{{msg.payload}}","layout":"row-spread","x":610,"y":360,"wires":[]},{"id":"29a91919.2b6b46","type":"function","z":"8db0322a.4cc4d","name":"transform dropdown message","func":"tx = msg.payload;\ntx = tx.substr(0, tx.length - 1);\nmsg.payload = tx;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":360,"wires":[["d4687052.28546"]]},{"id":"77c3f933.4bb528","type":"comment","z":"8db0322a.4cc4d","name":"add an \"$\" to every value","info":"","x":370,"y":200,"wires":[]},{"id":"b3bf38a.04a90c8","type":"comment","z":"8db0322a.4cc4d","name":"\"$\" lets dropdown recognize string only","info":"","x":690,"y":200,"wires":[]},{"id":"98cfba9c.d15eb8","type":"comment","z":"8db0322a.4cc4d","name":"reduce \"$\" from the end","info":"","x":370,"y":320,"wires":[]},{"id":"807b5c7.909b2a","type":"ui_group","name":"Group 1","tab":"4b4528d.4e9cad8","order":1,"disp":true,"width":6},{"id":"4b4528d.4e9cad8","type":"ui_tab","name":"Example","icon":"dashboard","order":8,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)
#### Post date: [17 May 2021 19:17 UTC](https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454/22 "2021-05-17T19:17:52Z")

</div>

This is how i solved it in the meantime.  
Works fine for me.  
Thanks to all who helped to solve it!

Tim

---

<div class="post-metadata">

### Author: ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)
#### Post date: [17 May 2021 21:22 UTC](https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454/23 "2021-05-17T21:22:18Z")

</div>

Hello dceejay,

fix 2.29.1 works for me.

Thanks a lot

Tim

---

<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: [16 July 2021 21:22 UTC](https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454/24 "2021-07-16T21:22:56Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/dropdown-node-cuts-a-0-at-the-end/45454.md?page=1)
