I have a form where I have three radios with the same name but different value, when I choose one the database only saves the value of the first radio that appears in the form without respecting the selection as I can solve this?
This is my form
<div id="Tambor" class="tabcontent">
<div class="md-form form-sm">
<input type="text" id="idorden" class="form-control">
<label class="container">
<input type="radio" id="s1" value="1" name="tambor">
<span class="checkmark1"></span>
</label>
<label class="container">
<input type="radio" id="s1" value="2" name="tambor">
<span class="checkmark2"></span>
</label>
<label class="container">
<input type="radio" id="s1" value="3" name="tambor">
<span class="checkmark3"></span>
</label>
</div>
</div>
<div class="text-center mt-2">
<button class="btn btn-info" id="enviar">Enviar</button>
</div>
This is the Js that I work with
$(document).ready(function() {
$("#enviar").click(function(){
create();
});
});
function read(Id) {
$.ajax({
method: "POST",
url: "http://localhost:8080/api/API/dolly/",
data: {
param: 2,
Id: Id
}
}).done(function(data) {
$("#nel").empty();
if (data.length > 0) {
var html = "";
$.each(data, function(i) {
console.log(data[i]);
})
}
})
}
function create() {
if ($.trim($("#idorden").val()) && $.trim($("#s1").val())){
var idorden = $.trim($("#idorden").val());
var s1 = $.trim($("#s1").val());
$.ajax({
method: "POST",
url: "http://localhost:8080/api/API/dolly/",
data: {
param: 1,
idorden: idorden,
s1: s1
}
}).done(function(data) {
console.log('se mando');
read(0);
})
}
}