简体   繁体   中英

How to get radio and checkbox value in using Modal Bootstrap PHP Mysql

I want to add .val(tag) for checbox and .val(bahasa) for radio for displaying values of it in a Modal bootsrap. But it won't display any values of the selected radio nor checkbox in the Modal popup:( Does anyone know how to do the .val correctly for both radio and checkbox?

Here's my code:

      <script>
            $(document).on("click", "#tombolUbah", function() {
                let id = $(this).data('id');
                let judul = $(this).data('judul');
                let penulis = $(this).data('penulis');
                let tahun = $(this).data('tahun');
                let deskripsi = $(this).data('deskripsi');
                let gambar = $(this).data('gambar');
                let tag = $(this).data('tag');
                let bahasa = $(this).data('bahasa');

                $("#id_buku").val(id);
                    $("#judul_buku").val(judul);
                    $("#penulis_buku").val(penulis);
                    $("#tahun_terbit").val(tahun);
                    $("#deskripsi").val(deskripsi);
                    $("#gambar").val(gambar);
                    $("#tag").val(tag);
                    $("#bahasa").val(bahasa);
            })
        </script>

Thank you so much:)

Getting values from the checkbox :

$( "input[type=checkbox][name=tag]:checked" ).val();

Getting values from the RadioBox :

$( "input[type=radio][name=bahasa]:checked" ).val();

reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM