activar radiobutton con texto también
Publicado por Eduardo (186 intervenciones) el 30/09/2022 04:38:39
Hola a todos.. espero esten todo bien... tengo el siguiente código que activa el radiobutton si se hace clic en la imagen respectiva, pero me gustaria que también este se activara al hacer clic en el texto respectivo para cada radiobutton como hago para ponerle a cada texto un id que este se active en el switch. espero me puedan ayudar!!! Mil gracias..!!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<table width='237' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='23' colspan='4' bgcolor='#FF6600'><center>
<span style='font-size: 12px; font-family: Arial, Helvetica, sans-serif; color: #000;'><b>Califique la Atención</b></span>
</center></td>
</tr>
<tr>
<td width='56' height='34' bgcolor='#FFFFFF'><center>
<img src='excelente.png' width='20' height='20'>
</center></td>
<td width='54' bgcolor='#FFFFFF'><center>
<img src='bueno.png' width='20' height='19'>
</center></td>
<td width='58' bgcolor='#FFFFFF'><center>
<img src='regular.png' width='20' height='19'>
</center></td>
<td width='69' bgcolor='#FFFFFF'><center>
<img src='malo.png' width='20' height='18'>
</center></td>
</tr>
<tr>
<td bgcolor='#FFFFFF'><center>
<span style='font-family: Arial, Helvetica, sans-serif; font-size: 10px'>Muy Satisfecho</span>
</center></td>
<td bgcolor='#FFFFFF'><center>
<span style='font-family: Arial, Helvetica, sans-serif; font-size: 10px'>Satisfecho</span>
</center></td>
<td bgcolor='#FFFFFF'><center>
<span style='font-size:10px; font-family:Arial, Helvetica, sans-serif'>Poco Satisfecho</span>
</center></td>
<td bgcolor='#FFFFFF'><center>
<span style='font-family: Arial, Helvetica, sans-serif; font-size: 10px'>Nada Satisfecho</span>
</center></td>
</tr>
<tr>
<td bgcolor='#FFFFFF'><center><input type='radio' name='RadioGroup1' value='4' id='RadioGroup1_4'></center></td>
<td bgcolor='#FFFFFF'><center><input type='radio' name='RadioGroup1' value='3' id='RadioGroup1_5'></center></td>
<td bgcolor='#FFFFFF'><center><input type='radio' name='RadioGroup1' value='2' id='RadioGroup1_6'></center></td>
<td bgcolor='#FFFFFF'><center><input type='radio' name='RadioGroup1' value='1' id='RadioGroup1_7'></center></td>
</tr>
<tr>
<td height='39' colspan='4' bgcolor='#FFFFFF'><center><input type='submit' name='button' id='button' value='Calificar'></center></td>
</tr>
<tr>
<td height='19' colspan='4' bgcolor='#FFFFFF'><input name='mailj' type='hidden' id='mailj' value='$mailj' />
<input name='nombrecomplett' type='hidden' id='nombrecomplett' value='$nombrecomplett' />
<input name='municc' type='hidden' id='municc' value='$municipio' />
<input name='tramitee' type='hidden' id='tramitee' value='$tramite' /></td>
</tr>
</table>
<script>
document.querySelectorAll('table td').forEach(function(elem) {
elem.addEventListener('click', function(e) {
switch (e.path[0].attributes[0].nodeValue) {
case 'excelente.png':
elem.parentNode.nextElementSibling.nextElementSibling.childNodes[1].lastChild.children[0].checked=true;
break;
case 'bueno.png':
elem.parentNode.nextElementSibling.nextElementSibling.childNodes[3].lastChild.children[0].checked=true;
break;
case 'regular.png':
elem.parentNode.nextElementSibling.nextElementSibling.childNodes[5].lastChild.children[0].checked=true;
break;
case 'malo.png':
elem.parentNode.nextElementSibling.nextElementSibling.childNodes[7].lastChild.children[0].checked=true;
break;
default:
break;
}
});
});
</script>
Valora esta pregunta


0