I have a form, with a simple select box, and I also have a text field that pulls a value. I want to use the value in $Defaultselection
as the default value for
That should do it:
<select >
<option value="1" <?php echo ($Defaultselection == 1)?"selected":""; ?>>A</option>
<option value="2" <?php echo ($Defaultselection == 2)?"selected":""; ?>>B</option>
<option value="3" <?php echo ($Defaultselection == 3)?"selected":""; ?>>C</option>
<option value="4" <?php echo ($Defaultselection == 4)?"selected":""; ?>>D</option>
</select>
or this other one:
<select >
<option value="1" <?php if ($Defaultselection == 1) echo "selected"; ?>>A</option>
<option value="2" <?php if ($Defaultselection == 2) echo "selected"; ?>>B</option>
<option value="3" <?php if ($Defaultselection == 3) echo "selected"; ?>>C</option>
<option value="4" <?php if ($Defaultselection == 4) echo "selected"; ?>>D</option>
</select>