1
I have the following code.
Html:
<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">
Javascript:
$(function () {
$("#botao").click(function () {
$("textarea[name='arraytextArea[]'],input[name='grupo1'],input[name='grupo2']" ).each(function (i,el) {
alert("Valor:"+$(el).val());
});
})})
You can also see on jsfiddle
I want to concatenate the spans elements of each radio group. As noted in the code we have the first group identified by Teg name="group1", so I have to concatenate all spans that are in this group and in all other groups.Guarding each concatenation of each group in a vector index.
NOTE: The code has to be used for numerous groups and numerous radios.
EX.:
vet[0]="valor1,valor2,valo3,valo4"; relativo ao name="grupo1"
vet[1]="Valor2,valor3,valor4,valor5"; relativo ao name="grupo2"
You want to do this by clicking the button?
– Sam
yes!!!!!!!!!!!!
– thiago