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

i have a code like this

<select name="pilih_notran">
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>";

but why it can't selected ?

El Forum

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