# Interdependent Widgets in one Cell

**URL:** <https://discourse.julialang.org/t/interdependent-widgets-in-one-cell/98351>\
**Category:** Pluto\
**Tags:** pluto, pluto-markdown\
**Created:** [May 4, 2023, 10:18pm UTC](https://discourse.julialang.org/t/interdependent-widgets-in-one-cell/98351 "2023-05-04T22:18:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoodDayToYouAll](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GoodDayToYouAll](https://discourse.julialang.org/u/GoodDayToYouAll)\
**Post date:** [May 4, 2023, 10:18pm UTC](https://discourse.julialang.org/t/interdependent-widgets-in-one-cell/98351/1 "2023-05-04T22:18:36Z")

</div>

Hi everyone,

I am quite new to Pluto and I am a little stuck. Also I don’t know how to properly include Pluto code here, if this is possible, please tell me.

* * *

**Core Problem:**

As to my question: In principle I want to access the value of a `Slider` in the same cell the `Slider` is defined; let’s say as the maximum value of another `Slider`. Ideally I want to do this inside a `combine` environment. So my aim is something like this:

```julia
function test()

	return combine() do Child
		md"""
		$(Child("First", @bind maxVal Slider(1:10, show_value=true, default=5)))
		$(Child("Second", Slider(1:maxVal, show_value=true)))
		"""
	end

end

```

What happens now is that the second `Slider` correctly starts with the range `1:5` but does not adjust it as I change the first `Slider`.

I also tried to implement this in a simpler Version without `combine` like this

```julia
md"""
$(@bind maxVal Slider(1:10, show_value=true, default=5))
$(Slider(1:maxVal, show_value=true))
"""

```

This does however behave in the same way. Weirdly enough I had a notebook where the latter still worked as intended but now I cannot replicate the behavior.

Is what I want to do possible in `Pluto`? I would greatly appreciate any help.

I know that in this case it is easily fixed by just splitting to two cells. Therefore I included some further context to show why I am interested in this in the first place.

* * *

**Motivation**

I would like it in one cell for two reasons:

1. The actual code I have in mind is much more complicated and I would like to reuse `test()` in a number of places. So having it in one function is much more convenient.

2. I actually want to have a variable controlling how often `test()` appears. So what I actually have in mind is

```julia
function multi_test(n)

	return combine() do Child
		inputs = [
			md"""
			Test $i : $(Child(test()))
			"""
			for i in 1:n
		]

		md"""
		$inputs
		"""
	end
end

```

In this case all three ‘first’ `Slider`s also behave the same due to the `@bind` of `maxVal` in `test()`, which is an additional problem.

Thanks again for any help you can offer!

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [May 5, 2023, 11:05am UTC](https://discourse.julialang.org/t/interdependent-widgets-in-one-cell/98351/2 "2023-05-05T11:05:53Z")

</div>

I have the exact same problem… I’m also pretty sure that something like this

```julia
md"""
$(@bind maxVal Slider(1:10, show_value=true, default=5))
$(@bind otherVal Slider(1:maxVal, show_value=true))
"""

```

worked before, i.e. that changing `maxVal` would automatically update the limit of `otherVal` in the same cell.

But I also can’t reproduce that right now. Funnily enough, trying to start an older Pluto server (e.g. version 0.16) just results in an empty browser window on macOS / Julia 1.8.5 …

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [May 5, 2023, 7:48pm UTC](https://discourse.julialang.org/t/interdependent-widgets-in-one-cell/98351/3 "2023-05-05T19:48:28Z")

</div>

Instead I seemed to remember an Issue or a draft PR where the use of depending widgets all from the same cell was currently not supported.  
I have tried briefly to look for it between Pluto and PlutoUI issues/PRs but couldn’t find it…

Maybe @fonsp or @Pangoraw might chime in

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [May 7, 2023, 6:41pm UTC](https://discourse.julialang.org/t/interdependent-widgets-in-one-cell/98351/4 "2023-05-07T18:41:58Z")

</div>

Very interesting, thanks for the info! I guess it makes sense that it’s not supported, but my memory of using this “feature” is pretty vivid – I’m starting to doubt my sanity 😅
