This question already has an answer here:

I am trying to take a user's input, which will determine as list of results. I would like to show that list to the user, one result at a time. Something like the following (which is broken):

   Row[{"How many squares? ", InputField[Dynamic[x], Number]}],
   (*m=1 so that no out of range error for x < m:*)
   Row[{ButtonBox["Squares!", Evaluator -> Automatic, 
       ButtonFunction -> (m = 1; (r = Map[#^2 &, Range[x]]) &), 
       Appearance -> "DialogBox"] // DisplayForm}],
   Row[{SetterBar[Dynamic[m], Dynamic[Length[r]]]}],

It seems that the trouble I am running into is setter bar not taking a dynamic range. I also tried using previous and next buttons which would increment or decrement x modulo m, but Mod[m,x] wasn't happy with a dynamic argument either. Any help would be greatly appreciated.


marked as duplicate by Kuba, user9660, RunnyKine, MarcoB, Jens May 2 '16 at 17:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ First of all, Length[r] will be an integer which will not work as a second argument of a SetterBar. Moreover Dynamic head stays there so something like Dynamic @ Range @ Length @ r will not be recognized as a List correctly. You have to move that Dynamic outside the Setterbar. $\endgroup$ – Kuba May 2 '16 at 7:27

You can try with Manipulate

Manipulate[Row[{SetterBar[Dynamic[y], Range[x]], Dynamic[y]}], 
 {{x, 1,"Squares"}, InputField[#, Number] &}]

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.