Récupérer la valeur d'un bouton radio coché en javascript
J'essaie de récupérer la valeur d'un bouton radio coché pour pouvoir faire des tests sur ce qui doit être affiché, mais malheureusement je n'y arrive.
Pourriez vous m'aider s'il vous plait ?
Fonction javascript
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
function returnPreview(){
var matin_Apres = document.getElementById('matinOuApres').checked;
var matin_Apres2 = document.getElementById('matinOuApres').value;
//alert("matin_Apres "+matin_Apres);
//alert("matin_Apres2 "+matin_Apres2);
if (document.forms["popinDemiAbsPreview"].elements["matinOuApres"].checked == true ){
alert("bouton radio 1 : "+document.forms["popinDemiAbsPreview"].elements["matinOuApres"].value);
}
} |
Formulaire
Code:
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
|
<tr>
<td align="center">
<s:form name="popinDemiAbsPreview">
<s:hidden name="idPersonneDemiAbs" name="idPersonneDemiAbs" value="" />
<s:hidden name="indexDemiAbs" name="indexDemiAbs" value="" />
<table cellpadding=5 style="width:600;align:center;" class="cadre">
<tr>
<td style="text-align: center;">
Présent le :
</td>
</tr>
<tr>
<td style="text-align: center;">
<input type = "radio" name='matinOuApres' id='matinOuApres' value='matin'/>matin
</td>
</tr>
<tr>
<td style="text-align: center;">
<input type = "radio" name='matinOuApres' id='matinOuApres' value='apres'/>après midi
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="Valider" onclick="returnDemiAbsValue(this.form.matinOuApres);">
<br/><br/>
</td>
</tr>
</table>
</s:form>
<br/><br/>
</td>
</tr> |
je ne rentre pas dans mon alerte ...:/