-1
Hello, I have the following code below where I wanted to control the radios. I want there to be an "event" triggered when each finishes sweeping the entire group of radios 1 whose name is "group1". That is, at the end of each group of scanned radios a message is sent or a variable changes its status. ex: when you arrive in group 1 with value 4, a message must be sent. When you arrive at the last element of Grupo2, it must also trigger "event". This has to be DYNAMIC.For any other or quantity of radio elements.
$(function() {
$("#botao").click(function() {
$("textarea[name='arraytextArea[]'],input[name='grupo1'],input[name='grupo2']").each(function(i, el) {
alert("Valor:" + $(el).val());
});
})
});
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div>
<textarea name='arraytextArea[]'></textarea> <br>
<input type="radio" name="grupo1" value="Valor1"><span>Valor1</span>
<input type="radio" name="grupo1" value="Valor2"><span>Valor2</span>
<input type="radio" name="grupo1" value="Valor3"><span>Valor3</span>
<input type="radio" name="grupo1" value="Valor4"><span>Valor4</span>
<br><textarea name='arraytextArea[]'></textarea> <br>
<input type="radio" name="grupo2" value="Valor1"><span>Valor2</span>
<input type="radio" name="grupo2" value="Valor2"><span>Valor3</span>
<input type="radio" name="grupo2" value="Valor3"><span>Valor4</span>
<input type="radio" name="grupo2" value="Valor4"><span>Valor5</span><br>
<input type="button" value="Enviar" id="botao">
</div>
</body>
</html>
Wouldn’t it just be putting an Alert after the end of the foreach? I don’t know if I understood you correctly.
– Caique Romero
I realized another question ... This question was misworded.I told you what I really want to do at this link :https://answall.com/questions/279667/concatenar-elements-radio
– thiago