0

i am trying to generate a multiple chechkbox in codeigniter which will allow to send emails to the email selected from the checkbox.

The form_multiselect didnt help me ...

Thanks..

2
  • Multi-select is for a selection list, if you want a checkbox you need to use form_checkbox() multiple times. Commented Jan 31, 2013 at 8:03
  • try this helper class github.com/nu1ww/ci_multiple_checkbox it will help you Commented May 27, 2014 at 8:50

1 Answer 1

2

Here's some example code... don't use in production, there's only explanation how to proceed data / validation / view

CONTROLLLER

    function test() 
  {
 $this->load->helper(array('form', 'url'));
 $this->load->library('form_validation');

 $this->form_validation->set_rules('emailRecipient[]', 'User Mail', 'required');

  if ($this->form_validation->run() == FALSE)
        {
      $data['PreEmailRecipient'] = array(
                'mail 1' => '[email protected]',
                'mail 2' => '[email protected]',
                'mail 3' => '[email protected]',
                'mail 4' => '[email protected]',
                'mail 5' => '[email protected]',
                'mail 6' => '[email protected]',
                'mail 7' => '[email protected]',
                'mail 8' => '[email protected]',
                'mail 9' => '[email protected]'
                );
            $this->load->view('test',$data);
        }
        else
        {
      foreach ($this->input->post('emailRecipient') as $key => $value)
      {
        echo $value.'<br />';
        //your code....   
      }      
        }
    }

VIEW

<?php echo validation_errors(); ?>
   <?php echo form_open('welcome/test');?>
      <?php foreach($PreEmailRecipient as $key => $value) : ?>
        <input type="checkbox" name="emailRecipient[]" value="<?php echo $value;?>">&nbsp;<?php echo $key;?><br />
      <?php endforeach;?>  
        <input type="submit" value="Submit" />
    </form>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.