1

I have form like this using ckedito4 and normal textarea :

enter image description here

i want when user input something in ckeditor4 textarea and click a Preview isi artikel button the text that they create on ckeditor 4 will be showup at normal textarea below it. and my form code like this :

<div class="form-group" >
      <label>Isi Artikel</label>
      <textarea class="editor1" name="editor1" id="editor1"></textarea>
</div>
<div class="form-group" >
      <label>Preview Artikel</label>
      <div class='Partikel'>
      <button type="button" onclick="myPreview()" class="btn btn-primary">Preview Isi 
       Artikel</button>
      <textarea class="form-control" id="Partikel" rows="15" readonly></textarea>
      </div>
</div>

i already try using javascript like this:

<script>
function myPreview() {
var textarea = document.getElementById('editor1');
var result = document.getElementById('Partikel');

result.textContent = textarea.value;

}
</script>

and this:

<script>
function myPreview() {
var x = document.getElementById("editor1").value;
document.getElementById("Partikel").innerHTML = x;
}
</script>

both of code work if i just using normal textarea to normal textarea but using ckeditor4 to normal textarea this just doesnt work at all. How i do this using ckeditor textarea? thx for advance.

tyo
  • 83
  • 8

0 Answers0