0

i have a problem with my code, when I write content in my admin dashboard, the textarea to make a new line not working, what's wrong with my code ? this is the view

<div class="main-conatiner-inner">
    <?php 
    if(isset($error_upload)) {
        echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>' . $error_upload . '</div>';
    } ?>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <?php 
                        echo form_open_multipart('artikel/input');?>
                            <div class="col-6">
                                <div class="form-group">
                                    <label for="example-text-input" class="col-form-label">Judul</label>
                                    <input name="judul" class="form-control" type="text" value="" id="example-text-input" placeholder="Masukkan judul" required>
                                </div>
                                <div class="form-group">
                                    <label for="example-text-input" class="col-form-label">Konten</label>
                                    <textarea name="konten" class="form-control fwMultilineTextbox" aria-label="With textarea" style="width: 800px; height: 400px;" placeholder="Masukkan konten" required></textarea>
                                </div>
                                
                                <div class="form-group">
                                    <label for="exampleFormControlFile1">Masukkan Gambar</label>
                                    <input type="file" name="gambar" class="form-control-file" id="exampleFormControlFile1">
                                </div>
                                <div class="form-group">
                                    <button type="submit" class="btn btn-success btn-sm mb-3"><i class="fa fa-check"></i> Simpan</button>
                                    <button class="btn btn-info btn-sm mb-3" onclick="goBack()"><i class="fa fa-arrow-left"></i> Kembali</button>
                                </div>

                                <?php echo form_close(); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <script type="text/javascript">
                $('textarea').keypress(function(event) {
                      if (event.which == 13) {
                        event.preventDefault();
                          var s = $(this).val();
                          $(this).val(s+"\n");
                      }
                    });
            </script>

this is the input content

and this is the output

Harshana
  • 5,151
  • 1
  • 17
  • 27
Marc Jamal
  • 47
  • 1
  • 2
  • 12

0 Answers0