Test si bouton radio checked
Salut à tous,
Alors voilà mon problème.
J'essaye de faire une fonction en javascript qui me permet de vérifier si un bouton radio est checked mais quand je test, rien ne se passe..
Voila ma fonction :
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 38 39 40 41 42
|
function formAbonnement()
{
var xhr = null;
if(window.XMLHttpRequest)
{ // Firefox et autres
xhr = new XMLHttpRequest();
}
else
{
if(window.ActiveXObject)
{// Internet Explorer
try
{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else
{// XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
}
var requete = "";
requete += "proposition="+document.getElementsByName('proposition').value+"&choix="+document.getElementByName('choix').value;
xhr.open( 'POST', 'modele/abonnement.php', true);
if(document.getElementByName('choix').checked == true)
{
document.getElementById("FormAbo").submit();
}
else
{
alert("pas bon");
return false;
}
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(requete);
} |
et voila mon 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
|
<form name="FormAbo" action="index.php?page=abonnement&action=souscrire" method="POST" id="FormAbo" onsubmit="formAbonnement();return false;">
<table border>
<tr>
<td></td>
<td>Abonnement 1 mois<input type="radio"name="proposition" value="1" /></td>
<td> 25.00 Euros</td>
</tr>
<tr>
<td></td>
<td>Abonnement 3 mois<input type="radio"name="proposition" value="2" /></td>
<td> 70.00 Euros</td>
</tr>
<tr>
<td></td>
<td>Abonnement 6 mois<input type="radio"name="proposition" value="3" /></td>
<td> 150.00 Euros</td>
</tr>
<tr>
<td></td>
<td>Abonnement 9 mois<input type="radio"name="proposition" value="4" /></td>
<td> 250.00 Euros</td>
</tr>
<tr>
<td></td>
<td>Abonnement 12 mois<input type="radio"name="proposition" value="5" /></td>
<td> 350.00 Euros</td>
</tr>
</table>
Moyen de paiement : </br>
<input type="radio" name="choix" value="cartebleue"><img src="images/CB.jpg" height="128px" width="128px" ALIGN="middle"></br>
<input type="radio" name="choix" value="paypal"><img src="images/paypal.jpg" height="128px" width="128px" ALIGN="middle"></br>
<input type="radio" name="choix" value="cheque"><img src="images/cheque.png" height="128px" width="128px" ALIGN="middle"></br>
</br>
<input type="button" value="Valider" onclick="formAbonnement()" name="FormAbo""/>
</form> |
Voila, merci de m'éclairer ^^