mardi 25 février 2020

how can i get array value with javascript

I made a questionnaire and the user can choose more than one choice. this is my source code here I add ajax to store data.

@foreach($answer as $a)
<div class="col-6 mt-3">
<button data-icon="#" data-plhn="" class="btn btn-white btn-block border-0 answer"></button>
<span class="field-icon"><i class="fa " id=""></i></span>
</div>
@endforeach
<script type="text/javascript">
    $(document).ready(function(){
        $('.answer').click(function(){
            $('.answer').removeClass('selected');
            $('.fa-check-circle').removeClass('fa-check-circle text-white').addClass('fa-circle-o text-dark');
            $($(this).attr("data-icon")).removeClass('fa-circle-o text-dark').addClass('fa-check-circle text-white');
            $(this).addClass('selected');
            var jawaban = $(this).attr('data-plhn');
            var id_kuis = ;
            var token = '';
            var html_id = '.' + $(this).attr('id');
            $.ajax({
                url: "",
                type: "POST",
                data: {jawaban:jawaban,id_kuis:id_kuis,_token:token},
                dataType: 'json',
                success: function(data){
                }
            });
        });
    });
</script>

and this my button to next quiz

<a href="" class="btn btn-asdp border-0 px-5 py-2 shadow ml-3">Next</a>

I want to take the answer from the user but I am confused how to retrieve data arrays like this. can you help me, thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire