I am trying to iterate the foreach data and print in li format in the textarea field.below is my code

Viewed 36

in my output, li and ul are also printed, but I only want task data, not in one line of textarea.

<input type="teaxtarea" name="task" class="form-control task" value="
<ol>
<?php foreach($val['task'] as $task) { ?>
<li><?php echo $task; ?></li>
<?php } ?>
</ol>">
1 Answers

Use a contenteditable div. It's a lazy solution that has its shortcomings.

var editor = document.querySelector(".my-editor")

function save() {
  console.log(editor.innerHTML);
}
<div class="my-editor" contenteditable style="border: 1px solid gray">
  <ol>
    <li>My task 1 (edit me)</li>
    <li>My task 2</li>
    <li>My task 3</li>
  </ol>
</div>

<button onclick="save()">save</button>

Related