# How to set the initial value in a dropdown with dynamic options

**URL:** <https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251>\
**Category:** Ask us anything\
**Created:** [November 6, 2023, 3:10pm UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251 "2023-11-06T15:10:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sampannemans](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sampannemans](https://community.weweb.io/u/sampannemans)\
**Post date:** [November 6, 2023, 3:10pm UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/1 "2023-11-06T15:10:07Z")

</div>

Hello,

In my app I am displaying a “Region”. Here the user can update the name and the HQ location of that region. In Xano I have a database table of “companies” and a “regions” table. Each region has a company set as the HQ location.  
In WeWeb I have a dropdown with a dynamic list of options coming from a database table “companies” in Xano.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/71b201af7312b848f707cffdb3fb16931689f42a.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d8e9440690d3565e9e67cb47c8df3f7ce2660aa8.png)

Now I would like to set the initial value of this dropdown to the company that is set as the HQ location of this Region.

I’ve tried 100 different things but I couldn’t figure this out. Any advice on how to set the initial value correctly if you have a dynamic dropdown with data coming from Xano?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 6, 2023, 3:14pm UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/2 "2023-11-06T15:14:05Z")

</div>

In the field initial value you put the same id, that matches your desired preselected item, from the items that is plugged into the dynamic options. (Bwcause your ids are the values)

I think what you need to do, is do **“On Change”** → **“Change variable value - to the event value” (of your premade variable)** → **Bind the variable to the init value**

---

<div class="post-metadata">

**Author:** ![sampannemans](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sampannemans](https://community.weweb.io/u/sampannemans)\
**Post date:** [November 7, 2023, 8:40am UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/3 "2023-11-07T08:40:52Z")

</div>

Thank you, that solves my problem!

I do see a small error message in the editor as it’s expecting a string and not a number.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/e5d202090a4e17c8494a84fe431874001176cadf.png)

Although it’s not blocking anything, is there a way to get rid of this error?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 7, 2023, 8:44am UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/4 "2023-11-07T08:44:50Z")

</div>

I wouldn’t worry about it. For now, I don’t think there is a simple and fast fix.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [November 7, 2023, 10:41am UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/5 "2023-11-07T10:41:27Z")

</div>

your value it’s a number, the error says that is expecting a string. Eventually the value will be implicitly converted to string. You can add an explicit conversion, for example by wrapping it like this `String(YourValue)`

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 7, 2023, 11:07am UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/6 "2023-11-07T11:07:32Z")

</div>

I think that wouldn’t match the 0 in the select [‘id’] value, would it? I’m not sure whether it is a string at the end or nay. I remember that kanban had a problem with this, when you set “0” to the stack and 0 to the identifier.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [November 7, 2023, 11:51am UTC](https://community.weweb.io/t/how-to-set-the-initial-value-in-a-dropdown-with-dynamic-options/5251/7 "2023-11-07T11:51:13Z")

</div>

right, that would require to make the value in the options a string as well
