Probleme sur appel de radio dans une function

Résolu
cs_destiny Messages postés 249 Date d'inscription jeudi 17 février 2005 Statut Membre Dernière intervention 29 août 2011 - 10 oct. 2005 à 11:03
ptirouz Messages postés 1 Date d'inscription jeudi 24 mars 2005 Statut Membre Dernière intervention 19 octobre 2005 - 19 oct. 2005 à 14:38
Lo all,

Mon code:

echo " ".$danscamp." ";
echo " ".$aproxi."";

Generer:

<!--StartFragment --><input type='radio' name='opt12r' id='opt12r' value='1'> Dans le camping
<input type='radio' name='opt12r' id='opt12r' value='2'> A proximité

Ma function JS:

function CheckParam(Id) {
var optr = 'opt' + Id + 'r';
var opt = 'opt' + Id;
if (document.getElementById(Id).checked) {
if (document.getElementById(optr[0]).checked || document.getElementById(optr[1]).checked) {
document.getElementById(optr[0]).checked = false;
document.getElementById(optr[1]).checked = false;
}
}

et il me met :
document.getElementById(optr[0]) has not properties alors que j'ai regarder partout l'index des radio et bien nom[i] ... bored depuis 1 heure merci de m'aider jcapte pas la...

Merci d avance !

Try to dodge my skill noob!

3 réponses

cs_bultez Messages postés 13615 Date d'inscription jeudi 13 février 2003 Statut Membre Dernière intervention 15 octobre 2013 30
10 oct. 2005 à 11:28
Bonjour,
un ID doit être unique.
donc document.getElementById(optr[indice]).??
ne fonctionnera pas ==> générer des ID différents.
Cordialement. Bul. Site
3
cs_destiny Messages postés 249 Date d'inscription jeudi 17 février 2005 Statut Membre Dernière intervention 29 août 2011
10 oct. 2005 à 11:36
ben en faite look ca


<table align='center' cellpadding='4' cellspacing='0' class='total-tcarac text1'>
<tr>
<td colspan='3' class='gtitre'>Activités</td>
</tr>
<tr>
<td class='checkbox-carac'></td>
<td class='img-carac'></td>
<td class='name-carac'>Piscine</td>
</tr><tr id='opt10' name='opt10'>
<td colspan='3' class='option-carac'> Dans le camping A proximité</td>
</tr>
<tr>
<td class='checkbox-carac'></td>
<td class='img-carac'></td>
<td class='name-carac'>Rivière</td>
</tr><tr id='opt11' name='opt11'>
<td colspan='3' class='option-carac'> Dans le camping A proximité</td>
</tr>
<tr>
<td class='checkbox-carac'></td>
<td class='img-carac'></td>
<td class='name-carac'>Pêche</td>
</tr><tr id='opt12' name='opt12'>
<td colspan='3' class='option-carac'> Dans le camping A proximité</td>
</tr>
<tr>
<td class='checkbox-carac'></td>
<td class='img-carac'></td>
<td class='name-carac'>Planche à voile</td>
</tr><tr id='opt13' name='opt13'>
<td colspan='3' class='option-carac'> Dans le camping A proximité</td>
</tr>
<tr>
<td class='checkbox-carac'></td>
<td class='img-carac'></td>
<td class='name-carac'>Golf</td>
</tr><tr id='opt14' name='opt14'>
<td colspan='3' class='option-carac'> Dans le camping A proximité</td>
</tr>


voila a quoi sa ressemble, et sa marche pas ce que tu ma mis

et ce que tu appel indice et automatique c est de 0 a infini? c est pas a moi de mettre une balise dans le radio pour genere l indice

Try to dodge my skill noob!
0
ptirouz Messages postés 1 Date d'inscription jeudi 24 mars 2005 Statut Membre Dernière intervention 19 octobre 2005
19 oct. 2005 à 14:38
Le problème est que tu as 2 ID identique :
id='opt10r'</gras> value='1'> Dans le camping
id='opt10r'</gras> value='2'> ...
Et c'est interdit, la fonction GetElementById ne sait pas lequel prendre puisqu'il y en a 2 !

En faite la il faut utiliser ! getElementsByName et non pas <STRIKE>getElementById</STRIKE>
0
Rejoignez-nous