#need help

20 messages · Page 1 of 1 (latest)

mellow halo
#

I have 2 entries, I want to duplicate them and send them as an array, but only 1 data is sent, the data I duplicate does not go, my code is as follows ^

#

I duplicated and filled the inputs 3 times, but the data comes like this:

"madde_t" => array:1 [▼
0 => "dsadsa"
]
"madde_d" => array:1 [▼
0 => "dasdsa"
]

#

Only the first value comes

mellow halo
#

😦

#

i need help

silver ivy
#

maybe edit the question to a more readable way, so that people can help? #rules

mellow halo
#
<div id="maddeContainer">
<!-- İlk Madde Başlığı ve Açıklaması -->
<div class="form-row mt-1">
<div class="form-group col-4 m-0">
<label for="email" class="col-form-label s-12"><i class="icon-envelope-o mr-2"></i>Madde Başlığı</label>
<input name="madde_t[]" placeholder="Madde Başlığı" class="form-control r-0 light s-12" type="text">
</div>
<div class="form-group col-4 m-0">
<label for="roll1" class="col-form-label s-12">Madde Açıklaması</label>
<textarea name="madde_d[]" placeholder="Madde Açıklaması" class="form-control r-0 light s-12" type="text"></textarea>
</div>
<div class="form-group col-2 mt-4 pt-2">
<button class="btn btn-danger" type="button" onclick="deleteMadde()"><i class="icon icon-delete"></i>Satır Sil</button>
</div>
<div class="form-group col-2 mt-4 pt-2">
<button class="btn btn-success" type="button" onclick="addNewMadde()"><i class="icon icon-plus-circle"></i>Yeni Ekle</button>
</div>
</div>
                                       
</div>

#
<script>
    let maddeCounter = 1;

    function addNewMadde() {
        maddeCounter++;

        // Yeni Madde Container oluştur
        var newMaddeContainer = document.createElement('div');
        newMaddeContainer.className = 'form-row mt-1';

        // Yeni Madde Başlığı
        var newMaddeTitle = document.createElement('div');
        newMaddeTitle.className = 'form-group col-4 m-0';
        newMaddeTitle.innerHTML = '<label for="email" class="col-form-label s-12"><i class="icon-envelope-o mr-2"></i>Madde Başlığı</label>' +
            '<input name="madde_t[]" placeholder="Madde Başlığı" class="form-control r-0 light s-12" type="text">';

        // Yeni Madde Açıklaması
        var newMaddeDescription = document.createElement('div');
        newMaddeDescription.className = 'form-group col-4 m-0';
        newMaddeDescription.innerHTML = '<label for="roll1" class="col-form-label s-12">Madde Açıklaması</label>' +
            '<textarea name="madde_d[]" placeholder="Madde Açıklaması" class="form-control r-0 light s-12" type="text"></textarea>';

        // Yeni Ekle Butonu
        var newButtonDelete = document.createElement('div');
        newButtonDelete.className = 'form-group col-2 mt-4 pt-2';
        newButtonDelete.innerHTML = '<button class="btn btn-danger btn-remove" type="button" onclick="deleteMadde()"><i class="icon icon-delete"></i>Satır Sil</button>';

        var newButton = document.createElement('div');
        newButton.className = 'form-group col-2 mt-4 pt-2';
        newButton.innerHTML = '<button class="btn btn-success" type="button" onclick="addNewMadde()"><i class="icon icon-plus-circle"></i>Yeni Ekle</button>';

        // Yeni eklenen alanları, sayfaya ekleyin
        newMaddeContainer.appendChild(newMaddeTitle);
        newMaddeContainer.appendChild(newMaddeDescription);
        newMaddeContainer.appendChild(newButtonDelete);
        newMaddeContainer.appendChild(newButton);

      document.getElementById("maddeContainer").appendChild(newMaddeContainer);
    }
</script>
silver ivy
#

the script seems working fine here, probably just make sure the added elements are inside of the form

Example

<form action="test" method="post">
   @csrf
   <div id="maddeContainer">
    all the elements here
   </div>
</form>
mellow halo
#

the same code works in my different software

#

I still couldn't solve the problem

silver ivy
#

perhaps try to replicate it at a fresh project and share it via github?

#

probably there is silly mistake somewhere, as the code is working(my end).

mellow halo
#

i try it

#

can you see my all code in here:

silver ivy
#

saw the codes, but it just too many, and I don't see any maddeContainer

#

probably just wait for the pro to jump in