jeudi 25 mars 2021

how to get value of radio button and pass it to controller in laravel?

On my e-commerce website, to checkout, you have to choose a shipping address based on some of the address data that has been entered into the database previously. here's how my website looks like. this is the modal. if you click the 'Pilih Alamat' button, a modal will appear containing a list of addresses that can be selected using a radio button. each radio button has a value in the form of an id from that address.

My problem is I want to take the value from the radio button that is selected and display the address details according to the address id. My plan is, when the 'pilih alamat' button is clicked on the modal, the value of the radio button will be sent to the controller so that I can retrieve data from the database that matches that id. but I am very new to this and I don't know what I should do. Your advice will be very meaningful, thank you.

this is the code for the modal section :

<div id="qck-view-shop2" class="zoom-anim-dialog qck-inside mfp-hide" aria-labelledby="myModalLabel">
                    <div class="modal-dialog modal-xl modal-dialog-scrollable" style="overflow-y: initial !important; margin-top:-10px;">
                      <div class="modal-content">
                          <div class="modal-header">
                               <h4 class="modal-title" id="myModalLabel">Pilih Alamat</h4>
                          </div>
                          <div class="modal-body" style="max-height: calc(100vh - 200px); overflow-y: auto;">
                            <div class="list-group">
                              @foreach ($alamat[1] as $row)
                              <label class="list-group-item" style="padding-left:30px; margin-top:20px;">
                                <input class="form-check-input" type="radio" name="alamat" value="">
                                <p></p>
                                <p style="font-weight:bold; margin-top:-10px;"></p>
                                <p style="margin-top:-10px;"></p>
                              </label>
                              @endforeach
                            </div>
                          </div>
                          <div class="modal-footer">
                            <a type="button" class="btn btn-outline-success" id="modal_button" style="color:white;">Pilih Alamat</a>
                          </div>
                      </div>
                    </div>
                  </div>

Here is the code for the section showing the details of the selected address:

<h6>Alamat Pengiriman</h6>
            @if ($alamat[1]!=null)
              <div class="card">
                <div class="card-body">
                  <p></p>
                  <p style="font-weight:bold; margin-top:-10px;"></p>
                  <p style="margin-top:-10px;"></p>
                  <p> <a class="popup-with-move-anim" href="#qck-view-shop3">Edit</a> </p>
                </div>
              </div>


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3lP4yJb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire