简体   繁体   中英

Codeigniter form helper dropdown

I want to add both an ID and NAME for my drop down (so that I could get the value using jQuery. but it seems that CI won't allow. Is there another way?

$device = array(
        'name'  => 'device',
        'id'    => 'device'

      );
$device_opts = array(
              'monitor'  => 'Chair',
              'keyboard'    => 'Keyboard',
              'mouse'    => 'Mouse',
              'table'   =>  'table',
              'UPS'     =>  'UPS',
            );  


echo form_dropdown($device, $device_opts);

Try like

$device = array(
    'id'    => 'device'
  );
form_dropdown('device', $device_opts, '', $device);

You need to give name as first option for the DropDown and the remaining will come under extra options for that DropDown

尝试这个

echo form_dropdown("device", $device_opts,"","id='device'");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM