1
<div class="col-md-11 col-sm-10 col-xs-12 pd-le0 pd-ri0">
    <div class="col-md-6 col-sm-6 col-xs-12">   
        <div class="form-group ">
            <label class="control-label col-md-4 col-sm-4 col-sm-12" title="Which Key Person does the following information apply to?">Key ID</label>
            <div class="col-md-8 col-sm-8 col-xs-12">
              <?php /*Previos Entries :- $ValueTax['Person_id']*/
                     //print_r ($optionkey);exit;
                    echo form_dropdown('key_id['.$key.']', $optionkey,"",array('class'=>'form-control KeypeopleId','id'=>'Person_id['.$key.']','onchange'=>'addKeypeople(this.options[this.selectedIndex].text)'));
             ?>
             </div>
        </div>

v Hello, i am facing problem in the above code. The issue is when im going to select the dropdown,the form is not appear and im not able to prrocess ahead in the form after clickin on the dropdown

"$optionkey" Comes From here

<?php
$options = array(
  '0'=>'No',
  '1'=>'Yes',
);
$option="";
foreach($options as $key=>$value){
    $option .="<option value=".$key.">".$value."</option>";
}
$optionkeys="";
foreach($optionkey as $key=>$value){
    $optionkeys .="<option value=".$key.">".$value."</option>";
}

?> And This is my Model From where im Fetching Keyid

function get_key_people($user_id){
    //print_r ($user_id);exit;
    $this->db->select('Key_Person_ID,Key_ID');
    $this->db->from('key_people'); 
    $this->db->where('user_FK',$user_id); 
    $this->db->where('is_delete',0);
    $result=$this->db->get()->result_array();
    $ar=array(''=>"Select",'ADDNEW'=>"ADD NEW");
    foreach($result as $key=>$value){
        $ar[$value['Key_Person_ID']]=$value['Key_ID'];
    }
    return $ar;
}

What is going on here?

Cœur
  • 37,241
  • 25
  • 195
  • 267
RK infotech
  • 61
  • 1
  • 11

1 Answers1

0

You don't need to handle the $optionkey by your self. In CI, form_dropdown function automatically add <select></select> and <option></option> tags.

form_dropdown([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]])
$name (string) -- Field name
$options (array) -- An associative array of options to be listed
$selected (array) -- List of fields to mark with the selected attribute
$extra (mixed) -- Extra attributes to be added to the tag either as an array or a literal string

This function is in \system\helpers\form_helper.php manual: https://codeigniter.com/user_guide/helpers/form_helper.html

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Chance
  • 1
  • 2