# Dropdown list imported from lists

**URL:** <https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641>\
**Category:** OpenEMR Development\
**Tags:** question\
**Created:** [June 18, 2022, 8:47am UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641 "2022-06-18T08:47:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriella\_Shebly](https://community.open-emr.org/user_avatar/community.open-emr.org/gabriella_shebly/32/17123_2.png) [@Gabriella\_Shebly](https://community.open-emr.org/u/Gabriella_Shebly)\
**Post date:** [June 18, 2022, 8:47am UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641/1 "2022-06-18T08:47:04Z")

</div>

I have this line of code:

 \<?php // echo generate\_select\_list('form\_abook\_type', 'abook\_type', ($row['abook\_type'] ?? null), '', 'Unassigned', 'form-control-sm', 'typeSelect(this.value)'); ?\>

that leads to the image below where we imported the address book types from the list:

 ![1](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/1/1/119be43e85f666c8a834f526601949a194d826d9.png)

I want to do this as well but for the states ( I changed name of State to Kaza in the figure), but I think I am missing something or the list name is wrong, does anyone know what is the correct name fore the States list if I want to add it to my code

code I am trying to change that was inspired from the code above:

\<?php echo generate\_select\_list('form\_abook\_state', 'abook\_state', ($row['state'] ?? null), '', 'Unassigned', 'form-control-sm', 'typeSelect(this.value)'); ?\>

![2](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/0/2/0276c5435cb551fd0ae92de4339af81972b8b05a.png)  
Empty list of states

full code can be found in addrbook\_edit.php

---

<div class="post-metadata">

**Author:** ![adunsulag](https://community.open-emr.org/user_avatar/community.open-emr.org/adunsulag/32/12606_2.png) [@adunsulag](https://community.open-emr.org/u/adunsulag)\
**Post date:** [June 18, 2022, 1:56pm UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641/2 "2022-06-18T13:56:07Z")

</div>

As far as I know the list\_id should be **state** not **abook-state**.

---

<div class="post-metadata">

**Author:** ![Gabriella\_Shebly](https://community.open-emr.org/user_avatar/community.open-emr.org/gabriella_shebly/32/17123_2.png) [@Gabriella\_Shebly](https://community.open-emr.org/u/Gabriella_Shebly)\
**Post date:** [June 18, 2022, 2:57pm UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641/3 "2022-06-18T14:57:22Z")

</div>

Thank you! The list is now populated 🙂  
I do have one more question, do you have any idea why the selected value isn’t being saved into the database? is there some other line of code that should be edited with the one mentioned above?

---

<div class="post-metadata">

**Author:** ![adunsulag](https://community.open-emr.org/user_avatar/community.open-emr.org/adunsulag/32/12606_2.png) [@adunsulag](https://community.open-emr.org/u/adunsulag)\
**Post date:** [June 18, 2022, 3:08pm UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641/4 "2022-06-18T15:08:16Z")

</div>

The form field name in the Address book is form\_state. You need to make your generated select statement have the same form name in order for the data to save properly. I believe in your example its the **form\_abook\_state** in the first argument, but don’t know for sure, so you’d need to test it out.

 ![image](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/5/a/5a930f1fcc0fc16156b305eedc0f37e3a92d150c.png)

---

<div class="post-metadata">

**Author:** ![Gabriella\_Shebly](https://community.open-emr.org/user_avatar/community.open-emr.org/gabriella_shebly/32/17123_2.png) [@Gabriella\_Shebly](https://community.open-emr.org/u/Gabriella_Shebly)\
**Post date:** [June 18, 2022, 3:11pm UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641/5 "2022-06-18T15:11:30Z")

</div>

It worked!!! Thank you so much

---

<div class="post-metadata">

**Author:** ![adunsulag](https://community.open-emr.org/user_avatar/community.open-emr.org/adunsulag/32/12606_2.png) [@adunsulag](https://community.open-emr.org/u/adunsulag)\
**Post date:** [June 18, 2022, 3:21pm UTC](https://community.open-emr.org/t/dropdown-list-imported-from-lists/18641/6 "2022-06-18T15:21:16Z")

</div>

I’ve been meaning to get around to having the address book state and country lookup use the standard openemr dropdowns. If you have this working, it would be great to contribute your code to OpenEMR via a pull request.

See our contributing readme here (Step 9 is the most relevant once you have your code on github) if you’ve never done a pull request before [openemr/CONTRIBUTING.md at master · openemr/openemr · GitHub](https://github.com/openemr/openemr/blob/master/CONTRIBUTING.md).
