php - Selected value is not selected in drop down list -
i using genericlist dropdown list in codeigniter.
here controller code dropdown list of question status:
$question_stat= $this->mdl_mcb_data->getstatusoptions ('ques_status'); array_unshift($question_stat,$this->mdl_html->option('','select question status')); $active = 1; $question_status = $this->mdl_html->genericlist($question_stat,"question_status",array('class'=>''),'value','text',$active); here view page part:
<tr> <th><label><?php echo $this->lang->line('status'); ?>: </label></th> <td><?php echo $question_status;?></td> </tr> when use firebug see html part, shows:
<tr> <th> <label>question status: </label> </th> <td> <select id="question_status" class="validate[required] text-input" name="question_status"> <option value="">select question status</option> <option value="0">inactive</option> <option selected="selected" value="1">active</option> </select> </td> </tr> that want selected. in dropdown list, selected value not displayed selected.
note:
no code error @ all. firebug shows desired result selected. but, in dropdown list, selected value not selected. might reason?
i got tricky solution own question. added following code @ top of view page:
<script language="javascript"> $(document).ready(function(){ cancel(); showquestionlist(); $('#question_status').val('1'); $("#frm_question").validationengine('attach', { onvalidationcomplete: function(form, status){ if(status==true){savequestion();}} }); }) </script> here, did added following line of code:
$('#question_status').val('1');
and worked perfectly.
Comments
Post a Comment