# Populate "choice" tag at runtime

**URL:** <https://community.hubspot.com/t/populate-choice-tag-at-runtime/74223>\
**Category:** CMS Development\
**Created:** [February 1, 2023, 9:21am UTC](https://community.hubspot.com/t/populate-choice-tag-at-runtime/74223 "2023-02-01T09:21:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyboox](https://avatars.discourse-cdn.com/v4/letter/x/a6a055/32.png) [@xyboox](https://community.hubspot.com/u/xyboox)\
**Post date:** [February 1, 2023, 9:21am UTC](https://community.hubspot.com/t/populate-choice-tag-at-runtime/74223/1 "2023-02-01T09:21:46Z")

</div>

Hello,

I have this scenario: we have a firebase database with some data ( let’s say some articles ). We’d like to use a “choice” tag or field ( although with field I believe is not possible ) for allowing an editor to select which set of data ( article ) to be used in a template for creating a webpage. For example: we would have a dropdown selector ( generated by a choice tag ) with article titles as options. When the editor selects one of those, the template would use selected set of data.

Is this possible? I tried this code in \<head\> of the template:

```lia-code-sample
{% require_js %}
<script>
window.choices = ... // async request using fetch to grab and properly format for "choices" the article titles from firebase. An example of the variable content would be: "First article title, Second article title"
</script>
{% end_require_js %}

{% choice "select_article" label="Select Article", choices="{{window.choices}}" export_to_template_context=true %}

```

but since choice tag is rendered by hubspot systems server side ( and so before the page reaches the browser ), obviously window.choices = null.  
Would this be a use case for a serverless function? Not sure if that can be executed server side before page being sent to the client.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [February 1, 2023, 9:02pm UTC](https://community.hubspot.com/t/populate-choice-tag-at-runtime/74223/2 "2023-02-01T21:02:36Z")

</div>

Hi, @xyboox 👋 Thanks for including those details. Hey, @stefen @Teun @louischausse, do you have any insight you can share with @xyboox?

Thank you very much! — Jaycee

---

<div class="post-metadata">

**Author:** ![stefen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefen/32/29274_2.png) [@stefen](https://community.hubspot.com/u/stefen)\
**Post date:** [February 3, 2023, 1:46pm UTC](https://community.hubspot.com/t/populate-choice-tag-at-runtime/74223/3 "2023-02-03T13:46:39Z")

</div>

[@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) @xyboox have you considered migrating that content to HubSpot’s HubDB? You could also leave the data there but use a serverless function to sync that data to HubDB.
