# \[?\] Avoid issue with PopupMenu?

**URL:** <https://community.wolfram.com/t/avoid-issue-with-popupmenu/13772>\
**Category:** Questions\
**Tags:** mathematica, interface-construction\
**Created:** [March 11, 2019, 1:04pm UTC](https://community.wolfram.com/t/avoid-issue-with-popupmenu/13772 "2019-03-11T13:04:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt2](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@matt2](https://community.wolfram.com/u/matt2)\
**Post date:** [March 11, 2019, 1:04pm UTC](https://community.wolfram.com/t/avoid-issue-with-popupmenu/13772/1 "2019-03-11T13:04:40Z")

</div>

I have a problem with `PopupMenu` inside `DynamicModule`, its values don’t update dynamically as they supposed to. The example below demonstrates the issue.

```
DynamicModule[{inputData = 0, dataSet1 = {0}, popupSelection, value1, value2 }, 
 Dynamic@Column[{
    InputField[Dynamic[inputData]], 
    Button["Plot", dataSet1 = Table[inputData + i^j, {i, 5}, {j, 2}]],
     Spacer[5],
    PopupMenu[Dynamic[popupSelection], {value1 -> "v1", value2 -> "v2"}],
    ListPlot[popupSelection, Joined -> True, ImageSize -> {300}, 
     Frame -> True]}],
 Initialization :> (
   value1 = dataSet1;
   value2 = dataSet1 + 1;
   ), 
 SynchronousInitialization -> False]

```

The `PopupMenu` is linked to `ListPlot`, for example: if `value1` with label “v1” is selected from the list then ListPlot should print the evaluated value of `value1` and the same goes for `value2`.

The problem I have is that `value1` and `value2` which correspond to `popupSelection` don’t update dynamically when changing the input of `InputField` and pressing button “Plot”. These values evaluate only once (upon `DynamicModule` evaluation) using initial values and they do not re-evaluate when required. I tried to wrap expressions of `value1` and `value2` with `Dynamic` but it conflicts with `ListPlot` giving me bunch of error messages.

I know i’m missing something here, I just can’t figure out what it is. Please help!

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [March 11, 2019, 1:59pm UTC](https://community.wolfram.com/t/avoid-issue-with-popupmenu/13772/2 "2019-03-11T13:59:46Z")

</div>

I would do it this way:

```
DynamicModule[{inputData = 0, dataSet1 = {0, 1}, popupSelection}, 
 Dynamic@Column[{InputField[Dynamic[inputData]], 
    Button["Plot", dataSet1 = Table[inputData + i^j, {i, 5}, {j, 2}]],
     Spacer[5], 
    PopupMenu[
     Dynamic[popupSelection], {"value1" -> "v1", "value2" -> "v2"}], 
    ListPlot[If[popupSelection === "value1", dataSet1, dataSet1 + 1], 
     Joined -> True, ImageSize -> {300}, Frame -> True, 
     Axes -> False]}],
 SynchronousInitialization -> False]

```

---

<div class="post-metadata">

**Author:** ![matt2](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@matt2](https://community.wolfram.com/u/matt2)\
**Post date:** [March 11, 2019, 2:41pm UTC](https://community.wolfram.com/t/avoid-issue-with-popupmenu/13772/3 "2019-03-11T14:41:17Z")

</div>

It resolves my problem, Thanks.
