php - set_value for select field option in codeignitor -
i wonder set_select
select field in codeigniter. try many ways doesn't work.
i have variable here $date_dossier = date_parse($patient['patient_date_dossier']);
doesn't defined function below:
<?php echo form_error('dossier_day') ?> <?php $option_day = array( '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30', '31' => '31' ); echo'<select name="dossier_day" class="form" id="day">'; ($a = 1; $a <= 31; $a++) { ?> <option value="<?php echo $a < 10 ? '0' . $a : $a ?>"> <?php if($a==$date_dossier['day']){ echo 'selected='.'"'.$a.'"'; }?> <?php echo $a < 10 ? '0' . $a : $a ?></option> <?php } echo'</select>'; echo '<span style="color:red">'.form_error('dossier_day').'</span>' ?>
<?php echo form_error('dossier_day'); $option_day = array( '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30', '31' => '31' ); $d_dossier = $date_dossier['day']; if (intval($d_dossier) < 10) $d_dossier = sprintf('%02d', $d_dossier); $extra = array("class" => "form" "id" => "day"); echo form_dropdown('dossier_day', $options_day, $d_dossier, $extra); echo '<span style="color:red">'.form_error('dossier_day').'</span>'; ?>
Comments
Post a Comment