Changing the control parameters of Manipulate

I am trying to adjust the start and end points of a Manipulate function using variables that only change value if a certain condition is met. What is wrong with the code below?

ClearAll["Global*"];

Manipulate[

If[True, xinit = 3; xMax = 5;

, xinit=1; xMax=4;];

x,

{{x, xinit}, 1, xMax, 1}

]

• remove semicolon after xMax = 5 Dec 5, 2014 at 16:21
• Removing the semicolon still gave me an error... Dec 5, 2014 at 16:25
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Dec 5, 2014 at 16:33

Here's one way: make the range be a checkbox (to choose the desired range for the x variable). Also, place the xinit and xmax variables inside Dynamic so they react to the changed values.
Manipulate[If[range, xinit = 3; xMax = 5;, xinit = 1; xMax = 4;]; x,
`