CodeIgniter Forums
[Solved] Capturing value from Listbox - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [Solved] Capturing value from Listbox (/showthread.php?tid=71303)



[Solved] Capturing value from Listbox - davy_yg - 07-30-2018

Check this out:

views\email\blast.php


         <center>
                                <label for="input1">List Emails</label>
                                    <select name="listbox" id='pre-selected-options' multiple='multiple' size="7">

                                    <?php     
                                    foreach($email as $item){    
                                    
                                        echo '<option value="'.$item['email'].'">'.$item['email'].'</option>';                                   
                                        }                                    
                                    ?>
                                    </select>                                
          </center>     


controllers\email.php


       private function send_email($id){

             $this->load->model('EmailModel');

             // bikin to yg pake , nanti di explode
             $to = array();
             $to[] = $this->input->post('pre-selected-options');




I wonder if this line is correct:   $to[] = $this->input->post('pre-selected-options');

Supposing that many emails is being selected and I am trying to capture the value from the controller into $to[]  - how to do so?

Thanks in advance.


RE: Capturing value from Listbox - php_rocs - 07-31-2018

@davy_yg,

Is that a variable with a special character after it? Or is that suppose to be brackets?