javascript - 如何为多个单选按钮 Laravel Javascript 设置和获取 cookie
问题描述
我无法将测验答案保存到重复出现的单选按钮 cookie。
如何将已单击的单选按钮的值保存到 Cookie 中?
这是我的单选按钮刀片
<form action="" method="post">
<small class="text-muted">Pertanyaan ke 1 dari {{ count($quiz) }}</small>
<br>
@foreach($quiz as $q)
@php
$quiz_questions = App\QuizQuestion::where('quiz_id',$q->id)->orderBy('priority', 'asc')->get();
@endphp
@endforeach
@foreach($quiz_questions as $key=>$qq)
<div style="margin:1% 0%; padding:2%; background-color:#EEEEEE;">
<p><strong>{{$key+1}}) {{$qq->question}}</strong></p>
@php
$quiz_answers= App\QuizAnswer::where('quiz_question_id', $qq->id)->get();
@endphp
@foreach($quiz_answers as $qa)
<div class="radio-inline">
<label for="">
<input required type="radio" name="ans[{{$qq->id}}]" id="ans[{{$qq->id}}]" value="{{$qa->id}}">  {{$qa->answer}}
</div>
<br>
@endforeach
</div>
@endforeach
<button class="btn btn-default pull-right">Lanjut</button>
</form>
它看起来像这样
如果我想将我的单选按钮值保存到 Cookie 中,是否可以?
如果可以的话,我不知道怎么解决,也许你可以帮我解决它
我使用 Laravel 版本 7 和 javascript