I have checkbox function that can only select one value. If user choose option of other they have to insert the value.
And now I'm trying to get the value of the inserted input by the user.

But I got this in my console.log it's not displaying any value that I have inserted before.

How do I fix the jQuery in order to get the input value if user choose others as the option ?
let subject_type = '';
$('input[name="web[]"]').change(function() {
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
if (this.value != 'others') {
subject_type = this.value;
} else if (this.value == 'others') {
subject_type = $("#subject_name").val();
}
});
$("#subject").hide();
$("#oth_subject").change(function() {
if ($("#oth_subject").is(':checked')) {
$("#subject").show();
} else {
$("#subject").hide();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-lg-6 mb-30">
<label>Pick A Subject</label>
<div class="form-group">
<ul>
<li><label class="checkbox"><input type="checkbox" name="web[]" value="Science"> Science</label></li>
<li><label class="checkbox"><input type="checkbox" name="web[]" value="Math"> Math</label></li>
<li><label class="checkbox"><input type="checkbox" name="web[]" id="oth_subject" value="others">Others</label></li>
</ul>
</div>
</div>
<div class="col-lg-12 mb-30" id="subject" class="row">
<label><b><span style="color:#e60000;">*</span> Insert the subject you wish </b></label><br>
<div class="input-group-prepend">
<input class="from-control" type="text" id="subject_name">
</div>
</div>
I'm checking the value in the formData entries.
<div class="col-md-12">
<button type="button" sendForm ="submit()">SEND</button>
</div>
const sendForm = () =>{
let formData = new FormData();
//assuming I have another data just u show this
formData.append('subject', subject_type);
for (var pair of formData.entries()) {
console.log(pair[0]+ ', ' + pair[1]);
}
}
}

othersoption and inserted the value in the input. when I tried to submit the form I checking the value and it did not show any value that has been inserted in the inputOtherscheckbox and then I start to type some text insubject_nametextbox after that I can get the value of text box by$("#subject_name").val();in console. So what is the problem?