CodeIgniter Forums
[HELP] Keep a Select Box Selected after Submit - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: [HELP] Keep a Select Box Selected after Submit (/thread-53159.html)



[HELP] Keep a Select Box Selected after Submit - El Forum - 07-12-2012

[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


[HELP] Keep a Select Box Selected after Submit - El Forum - 07-12-2012

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