2

I am doing a project in codeigniter and I came across a problem of displaying multiple ckeditor for objective answer to a question in my view.

   <div class="col-md-6">   
   <textarea id="objective_answer" name="objective_answer"><?php echo set_value('objective_answer', $answer); ?></textarea>   
    <?php echo form_ckeditor(array('id'=>'objective_answer'));  ?>

     </div>

    <?php  }  ?>

The above code displays one ck editor fine.But I have to show lets say 4 ckeditor for writing 4 objective answers to a question. Can anyone help me how to do this?

2
  • Put different ids. The id html attribute should be unique on the page.
    – Vlad Preda
    Commented Sep 1, 2014 at 13:17
  • +1 facing the same problem
    – subash
    Commented Sep 7, 2014 at 0:58

1 Answer 1

1

create a counter and set unique ids for the text areas:

<?php for($i=0;$i<4;$i++){?>

<div class="col-md-6">   
    <textarea id="objective_answer<?php echo $i;?>" name="objective_answer">
        <?php echo set_value('objective_answer', $answer); ?>
    </textarea>   
    <?php echo form_ckeditor(array('id'=>'objective_answer'.$i));  ?>
</div>
<?php }

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.