# Accesing dropdown in js file

**URL:** <https://discourse.nodered.org/t/accesing-dropdown-in-js-file/45221>\
**Category:** Developing Nodes\
**Created:** [5 May 2021 13:20 UTC](https://discourse.nodered.org/t/accesing-dropdown-in-js-file/45221 "2021-05-05T13:20:00Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 May 2021 08:07 UTC](https://discourse.nodered.org/t/accesing-dropdown-in-js-file/45221/7 "2021-05-06T08:07:10Z")

</div>

> [@jake123](#):
>
> dont know how to make the right value selected in the list.

Did you try this...

```auto
              data.forEach((item) =>
                  let value = item.name;
                  let text = item.name;
                  options.push({ v: value, t: text, });
                  $("#node-input-options").append(
                    $("<option></option>").attr("value", value).text(text)
                  );
                  if(value == node.selectedValue) $('#node-input-options').attr('selected','selected'); //<<<<<
              );

```

What it does: as you build your `select`, if the **remembered selection** (`node.selectedValue`) matches the `value` being added to the options, set the `selected` attribute of the option being added to value `selected`.

This was pointed out [here](https://discourse.nodered.org/t/custom-node-with-values-from-global/44977/18) - did you try it?

---

_[View the full topic](https://discourse.nodered.org/t/accesing-dropdown-in-js-file/45221)._
