0
$\begingroup$

This is a modest extension of the example discussed in workflow/BuildAMultipageForm. I'd like to build a form so that the first page asks for the number of inputs and the second page asks for numeric values for each input. The extension is that the values should be ordered. So the value for input 2 should be greater than the value for input 1, etc. Dynamic handles that nicely on a Desktop. How to reproduce that in Forms?

I understand the values on a page aren't available until the user presses Next. So that suggests each value must be entered on a separate page. Clunky, but reasonable. How to do this? Are there more elegant solutions?

Kludgy, but workable alternatives:

  1. Just push the responsibility to the user and complain if the values aren't ordered
  2. Simply ask for the given number of values, sort them and then identify them based on the sorted order
  3. Ask for positive the differences in the values.
$\endgroup$

1 Answer 1

0
$\begingroup$

Hope this is useful to someone else on the learning curve. A FormFunction that returns a Manipulate. Manipulate handles the ordering neatly. Suggestions for better methods welcome!

FormFunction[{
  (* Select the number of modes *) 
  FormObject[{{"nModes", "Number of Modes"} -> <|
                      "Interpreter" -> Range[1, 10], 
                      "Control" -> SetterBar|>}, 
              AppearanceRules -> <|
                       "Title" -> "Select the number of modes"|>]},
 (*  Select the values for each mode *)
  DynamicModule[{rates},
      (* Set limits for the values: Between -10 and 10 *)
     rates[0] = -10;
     rates[#nModes + 1] = 10;
     Manipulate @@ 
         Join[{(* Display the rates *)
               Table[With[{i = i}, rates[i]], {i, 1, #nModes}]},
               (*  Select the n rates *)                                        
             Table[With[{i = i},
                  {{rates[i], i, "Rate " <> ToString[i]}, 
                    (* Lower limit from previous value *)
                    rates[i - 1] + 1/128, 
                    (* Upper limit from next value *)
                    rates[i + 1] - 1/128, 1/128, 
                    Appearance -> "Labeled"}],
               {i, 1, #nModes}]]] &]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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