简体   繁体   中英

how to add serial number selected option value

I have a select dropdown with multiple select option value

foreach ($this->view->getallbacklogs as $key => $value) {
  echo $i;
  echo '<option value="'.$value['b_id'].'"data-position="'.$i.'">'.$value['i_description'].'</option>';
  $i++;
}

Which is working well. Is there any way to add a serial number before option value.

eg:

1 open
2 closed 

etc.. Any help would be appreciated.

echo '<option value="' . $value['b_id'] . '" data-position="'.$i.'">' . $i.' '.$value['i_description'] . '</option>';

you can concatenate the position with your value and just add a space between like an empty string. It will work for what you are trying to achieve.

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