CodeIgniter Forums

Full Version: [HELP] Keep a Select Box Selected after Submit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]C_Line[/eluser]
i have a code like this

Code:
<select name="pilih_notran">
&lt;?php
$i=0;
foreach($query as $no)
{
$nos[$i] = $no->notrans_supplier;
$p = $_SESSION['psan'];
echo "<option id='$i' value='".$no-&gt;notrans_supplier ."' if($p == $nos[$i]){selected = 'selected';}>".$no->notrans_supplier."</option>";
$i++;
}
?&gt;
</select>

but why it can't selected ?
thx

El Forum

[eluser]CroNiX[/eluser]
Try using form_dropdown(). CI does all of that for you, and it's much cleaner.