I currently have an issue submitting form to the server. When I click on the Submit button, all the fields in the form get submitted but when I use $('#form3').submit(), just one field is submitted.
Find below my code to automatically submit the form on countdown equal to zero.
var countdown = 10000;//expire * 60 * 1000;
var timerId = setInterval(function(){
countdown -= 1000;
var min = Math.floor(countdown / (60 * 1000));
var sec = Math.floor((countdown - (min * 60 * 1000)) / 1000); //correct
if (countdown <= 0) {
$('#form3').submit();
alert("Time Up!");
clearInterval(timerId);
return false;
}else {
$("#showtime").html(min + " Min : " + sec + " Sec");
}
}, 1000); //1000ms. = 1sec.
The form markup
<form class="form-validation" id="form3" action="{{url('submit-form')}}" method="POST">
{{csrf_field()}}
<fieldset class="step" id="validation-step1">
<h6 class="form-wizard-title text-semibold">
Teacher's Instructions
<small class="display-block">Select the correct option.</small>
</h6>
<div class="row">
<p class="lead" style="margin-left: 60px;">{{@$question->question}}</p>
<div class="col-md-12">
<div class="col-md-6">
<p class="lead">Please, read the instructions carefully before you start.</p>
<br>
<input type="hidden" name="exam" value="{{@$exam->id}}">
</div>
</div>
</div>
</fieldset>
@php $i = 2; $sn=1; @endphp
@foreach(@$questions as $question)
@php
$options = collect([$question->option1, $question->option2, $question->option3, $question->option4, $question->option5])->shuffle();
@endphp
<fieldset class="step" id="validation-step{{@$i++}}">
<h6 class="form-wizard-title text-semibold">
<span class="form-wizard-count">{{@$sn++}}</span>
Question
<small class="display-block">Select the correct answer to the question.</small>
</h6>
<div class="row">
<p class="lead" style="margin-left: 60px;">{{@$question->question}}</p>
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group" style="margin-left: 40px;">
@foreach($options as $option)
<div class="radio">
<label class="lead">
<input type="radio" value="{{@$option}}" name="question[{{@$question->id}}]" class="">
{{@$option}}
</label>
</div>
@endforeach
</div>
</div>
<div class="col-md-6 text-center">
@if(@$question->image)
<img src="{{@$question->image}}" class="" style="width: 80%; height: 60%; border: 1px solid black; margin: 20px;">
@endif
</div>
</div>
</div>
</fieldset>
@endforeach
<div class="form-wizard-actions">
<button class="btn btn-default" id="validation-back" type="reset">Back</button>
<button class="btn btn-info" id="validation-next" type="submit">Next</button>
</div>
</form>
$('#form3').submit()?