# UI Dropdown - Populating Data

**URL:** https://discourse.nodered.org/t/ui-dropdown-populating-data/3281
**Category:** General
**Created:** [19 September 2018 18:35 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281 "2018-09-19T18:35:06Z")
**Posts on this page:** 9
**Page:** 2

<div class="post-metadata">

### Author: ![Miliks](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/miliks/32/7598_2.png) [@Miliks](https://discourse.nodered.org/u/Miliks)
#### Post date: [16 April 2019 10:44 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/21 "2019-04-16T10:44:18Z")

</div>

how i can do this? Which node?  
Can u give me a hint?

---

<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: [16 April 2019 10:48 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/22 "2019-04-16T10:48:49Z")

</div>

in your function where you create the options... just before the return add  
`msg.payload = "";`

---

<div class="post-metadata">

### Author: ![Miliks](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/miliks/32/7598_2.png) [@Miliks](https://discourse.nodered.org/u/Miliks)
#### Post date: [23 April 2019 08:41 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/23 "2019-04-23T08:41:36Z")

</div>

Works like a sharm! Thanks!

---

<div class="post-metadata">

### Author: ![niels\_devos](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@niels\_devos](https://discourse.nodered.org/u/niels_devos)
#### Post date: [16 May 2019 13:55 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/24 "2019-05-16T13:55:35Z")

</div>

I can't import this and it looks very interesting for me

---

<div class="post-metadata">

### Author: ![SinZapatillas](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@SinZapatillas](https://discourse.nodered.org/u/SinZapatillas)
#### Post date: [11 August 2020 13:50 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/25 "2020-08-11T13:50:15Z")

</div>

Hi, I am trying to do something similar as shown here. Basically I want to do a query to extract names and IDs and introduce it to the dropdown list, using the ID as the output value and the name as the shown text to the user. I have used your flow to convert it to an array, but I dont manage to archive it.

Here is the flow that Im using:

```auto
[{"id":"244b484f.eb8748","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"162a8e92.929ac1","type":"ui_dropdown","z":"244b484f.eb8748","name":"","label":"","tooltip":"","place":"Select option","group":"497a6f44.27083","order":3,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":0,"type":"num"}],"payload":"","topic":"","x":1100,"y":240,"wires":[[]]},{"id":"9accb523.207058","type":"function","z":"244b484f.eb8748","name":"","func":"msg.topic = \"SELECT ID_pac,Nombre FROM Pacientes\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":200,"wires":[["11cea2ce.4b369d"]]},{"id":"edacaec2.a7f99","type":"inject","z":"244b484f.eb8748","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":200,"wires":[["9accb523.207058"]]},{"id":"11cea2ce.4b369d","type":"mysql","z":"244b484f.eb8748","mydb":"2becde9d.a8a7b2","name":"","x":490,"y":220,"wires":[["5cb5f942.5260f8"]]},{"id":"5cb5f942.5260f8","type":"function","z":"244b484f.eb8748","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 msg.options.push(opt);//add the opt to array \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":220,"wires":[["162a8e92.929ac1"]]},{"id":"497a6f44.27083","type":"ui_group","z":"","name":"MODIFICAR DATOS:","tab":"46554696.69f0b8","order":3,"disp":true,"width":"12","collapse":false},{"id":"2becde9d.a8a7b2","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"test","tz":""},{"id":"46554696.69f0b8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Zbrooklyn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zbrooklyn/32/34446_2.png) [@Zbrooklyn](https://discourse.nodered.org/u/Zbrooklyn)
#### Post date: [8 January 2021 18:49 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/26 "2021-01-08T18:49:49Z")

</div>

I have a question how do I use payload in the opinion label

```auto
[
    {
        "msg.payload": "17260851BD"
    },
    {

```

```auto
msg.options=

[
    {
        "msg.payload": "17260851BD"
    },
    {
        "part_number_item2": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    },
    {
        "part_number_item": "17299989AC"
    },
    {
        "part_number_item": "17246783FB"
    }
];

return msg;

```

---

<div class="post-metadata">

### Author: ![gliepins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gliepins/32/45752_2.png) [@gliepins](https://discourse.nodered.org/u/gliepins)
#### Post date: [30 July 2021 16:16 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/27 "2021-07-30T16:16:48Z")

</div>

Hi, everyone!  
I must ask for help to do the following:

1. Create a dropdown with "projectIDs" and select one from the list;
2. Press a button to "start" the process with selected projectID;
3. Press a button (or same button) to end the process;
4. write that info into Influx db. "projectID"="StartTime"="EndTime"  
optional = populate the records with additional tags;  
optional = Combine multiple dropdowns with a context. Select 1st Dropdown with Categories, Then select 2nd Dropdown with corresponding items such as "projectIDs"

Hoping to find some clues or solutions!  
Thank You!

---

<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: [30 July 2021 16:35 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/28 "2021-07-30T16:35:51Z")

</div>

Welcome to the forum @gliepins

I would start by starting at the beginning of your list, and moving on the next point once the previous one is basically functioning. So starting with item 1 I suggest starting with the dashboard dropdown node.

However, since this is an old thread I suggest starting a new thread, since this one is already solved. I will close this one.

Also if you are a beginner then I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<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: [30 July 2021 16:36 UTC](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281/29 "2021-07-30T16:36:28Z")

</div>



[Previous page](https://discourse.nodered.org/t/ui-dropdown-populating-data/3281.md?page=1)
