# HTMLFormEntry use a custom attribute as the value instead of ID

**URL:** <https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202>\
**Category:** Development\
**Tags:** html-form-entry, htmlform, developers-forum\
**Created:** [January 6, 2020, 7:53am UTC](https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202 "2020-01-06T07:53:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mddubey](https://talk.openmrs.org/letter_avatar/mddubey/32/5_5575768a8748004e209b776fc1b2916d.png) [@mddubey](https://talk.openmrs.org/u/mddubey)\
**Post date:** [January 6, 2020, 7:53am UTC](https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202/1 "2020-01-06T07:53:51Z")

</div>

Hello People,

We are using HTML form entry to design our forms. In one of the forms, we want to perform some calculations based on the concept selected. The concept has a Custom Attribute `Ratings` which we want to use for calculation. We want to know how to get this attribute in our `javascript` files.

By default, the generated HTML looks like below

```auto
<input type="checkbox" id="w12" name="w12" value="165965" autocomplete="new-password">

```

Where the value `165965` is the ID of answer concept. We want this to be a `CustomAttributeValue` instead of ID.

Please let us know.

CC: @dkayiwa @ssmusoke@rrameshbtech @sukreet @vasanth2019 @mksd @mksrom

---

<div class="post-metadata">

**Author:** ![mksd](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mksd/32/11729_2.png) [@mksd](https://talk.openmrs.org/u/mksd)\
**Post date:** [January 6, 2020, 2:17pm UTC](https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202/2 "2020-01-06T14:17:10Z")

</div>

Hi @mddubey, do you want to fetch the ‘Ratings’ concept attribute from the concept ID within an HFE form?

---

<div class="post-metadata">

**Author:** ![mddubey](https://talk.openmrs.org/letter_avatar/mddubey/32/5_5575768a8748004e209b776fc1b2916d.png) [@mddubey](https://talk.openmrs.org/u/mddubey)\
**Post date:** [January 6, 2020, 3:07pm UTC](https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202/3 "2020-01-06T15:07:48Z")

</div>

Yes, we want to use this in our JavaScript calculations.

---

<div class="post-metadata">

**Author:** ![mksd](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mksd/32/11729_2.png) [@mksd](https://talk.openmrs.org/u/mksd)\
**Post date:** [January 6, 2020, 3:51pm UTC](https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202/4 "2020-01-06T15:51:55Z")

</div>

You can fetch the `Concept` by its ID using the Velocity function `fn.getConcept(String conceptId)`, and once you have it at hand get the wanted attribute. Have you tried that?

---

<div class="post-metadata">

**Author:** ![mddubey](https://talk.openmrs.org/letter_avatar/mddubey/32/5_5575768a8748004e209b776fc1b2916d.png) [@mddubey](https://talk.openmrs.org/u/mddubey)\
**Post date:** [January 6, 2020, 5:18pm UTC](https://talk.openmrs.org/t/htmlformentry-use-a-custom-attribute-as-the-value-instead-of-id/26202/5 "2020-01-06T17:18:39Z")

</div>

Sure, we can give this a try. However, in the scenario we want to avoid fetch all the concept as JavaScript variables.

> The scenario is, we have a few question concepts added to form. The answer concepts have a rating associated. We want to do some calculations based on the rating of answer selected for a particular questions.

If we try the above method, we will have to fetch all the answer concept with their ratings. This way we will loose flexibility of the adding new answers going forward.

Not sure, if this is possible or there is a different approach towards this?
