Drop down sub menu list depending on previous choice/selection

I am attempting to piece together dynamic variables to determine the submenu from a previous menu choice.

Choose a muscle motion to exercise:
<$select $tiddler=’$:/verb/exercise’ field=‘exercise’ default=‘Choose a new exercise’>
< option>abdominals< /option>
< option>pulling< /option>
< option>pushing< /option>
< option>squats< /option>
< option>hip_hinges< /option>
</$select>

suppose I have populated different exercise list inside different fields segregated by the muscle group.

list_abdominals: [[Woodpecker Plank]] [[Single Leg Reverse Jackknife]] [[Spiderman Crunches]] [[Starfish Crunches]] …
list_hip_hinges [[Barbell hip thrust]] [[Bear crawls ]] [[Bent-over row]] [[Clamshell]]…
list_pulling [[Fly Pull-Ups]] [[Foot-Supported L-Sit Hold]] [[Frog Pull-Ups]] [[Gorilla Pull-Ups]]…
list_pushing [[Side-to-Side Push-Ups]] [[Single-Arm Handstand Push-Ups]] [[Spiderman Push-Ups]]…

depending on the exercise group i would like the corresponding list option. So far I’ve figured out how to make the static syntax work.

Abdominal Exercise:<$select field=“exercise_abdominal”><$list filter="[list[!!list_abdominals]]">{{!!title}}</$list></$select>

dynamic syntax (not working)

{{!!exercise}} Exercise:<$select field={{!!exercise}}><$list filter="[list[list_{{!!exercise}}]]">{{!!title}}</$list></$select>

dynamic syntax alt (not working)

{{!!exercise}} Exercise:<$select field="{{!!exercise}}"><$list filter="[list[list_<$text text={{!!exercise}}/>]]">{{!!title}}</$list></$select>

  • if i print list_{{!!exercise}} it will print the text as it should: list_{{!!exercise}}
  • if i print list[list_<$text text={{!!exercise}} it will print the text as it should: list_<$text text={{!!exercise}}/>

then why its not feeding into command execution?

once i figure that out, I will also like to include a counter in the suffix for each field name exercise set on each entry for repetitions; in order to track which exercise set each repetition belongs to.

I’m guessing

{{!!exercise}}_repetion_set _ +indexes[]

1 Like

The problem is that while list_{{!!exercise}} displays the desired fieldname, you can’t use that syntax within the filter to construct and use that fieldname as the operand of the list[...] filter operator.

Try this instead:

{{!!exercise}} Exercise:
<$let fieldname={{{ [[!!list_]] [{!!exercise}] +[join[]] }}}>
<$select field={{!!exercise}}>
   <$list filter="[list<fieldname>]">
      <option value={{!!title}}>{{!!title}}</option>
   </$list>
</$select><br>
</$let>
  • First use a $let widget with “filtered transclusion” to join together the parts of the fieldname.
  • Then, use [list<fieldname>] to output the options within the “sub-menu” $select widget.

enjoy,
-e

Hey Eric,
Has anyone a showcase to understand how the different tiddler fit together ?

Best

My next objective is to track each number of sets of repetition per exercise. Exercises vary hence some exercises end at one set others at 8, on average 4. So I need a solution where it doesn’t matter how many.

how can I program dynamic field names such that sets can be added to the field name as its range field dial entry is put into that field’s value; with the press of a button; resetting the dial for the next set of repetitions, wash rinse and repeat.

repetitionOf_exerciseX_set_01:
repetitionOf_exerciseX_set_02:
repetitionOf_exerciseX_set_03:

my attempt made Java angry; flashing big red “Internal JavaScript Error” notices; I would have included a screenshoot of the insident except Java found the whole experience quite embarrasing.

here is my offensive syntax:

<$let repetition={{{ [[!!repetitionOf_]] [{!!exercise}] [[!!_set_]] +[indexes[]] +[join[]] }}}>
<$vars string="[[Set Number ]] +[indexes[]] +[join[]]">
<$range field=<repetition>  min="-1" max="10" default="1" increment="1"/> 
<br> Number of repetitions: {{!!<repetition>}}
<br> <$text text=<<string>>/>

<$button>
<$action-setfield $tiddler='$:/verb/exercise/' <<repetition>>={{$:/verb/exercise/<repetition>}} />
<<string>>
</$button>
</$vars>