Fonction js ok sous IE marche pas sous FF

Résolu/Fermé
KRzYamaneko Messages postés 3 Date d'inscription mardi 26 août 2008 Statut Membre Dernière intervention 27 août 2008 - 26 août 2008 à 17:08
KRzYamaneko Messages postés 3 Date d'inscription mardi 26 août 2008 Statut Membre Dernière intervention 27 août 2008 - 27 août 2008 à 10:03
Bonjour,
Voila je n'y connais rien en HTML ni Javascript, et après un petit temps j'ai produit un bout de code qui fonctionne sous Internet Explorer mais pas sous FireFox. Voilà le code

<html>
<head>
	<script language=javascript>
	function redirige()
	{
		if ((choix(0).checked)== 1)
		{
		document.location.href="http://krz.blogsite.org/nr.html";
		}
		if ((choix(1).checked)== 1)
		{
		document.location.href="http://krz.blogsite.org/se.html";
		}
		if ((choix(2).checked)== 1)
		{
		document.location.href="http://krz.blogsite.org/ar.html";
		}
		if ((choix(3).checked)== 1)
		{
		document.location.href="http://krz.blogsite.org/la.html";
		}
		if ((choix(4).checked)== 1)
		{
		document.location.href="http://krz.blogsite.org/au.html";
		}
	}
	</script>
</head>
  <body>
  <div style="width:200px;border:solid 1px #000;text-align:center">
  <img src="http://img211.imageshack.us/img211/8266/staarwarlo8.jpg">
  <table>
    <tr>
        <td valign="middle" style="height:200px;">
            <div>
				<table>
				<tr>
				<td><input type="radio" name=choix value=1>Nouvelle République</td>
				</td>
				<tr>
				<td><input type="radio" name=choix value=2>Séparatistes</td>
				</td>
				<tr>
				<td><input type="radio" name=choix value=3>Alliance Rebelle</td>
				</td>
				<tr>
				<td><input type="radio" name=choix value=4>L'Ancienne République</td>
				</td>
				<tr>
				<td><input type="radio" name=choix value=5 checked>Autres</td>
				</td>
				</table>
			</div>            
        </td>
    </tr>
	</table>
	<input type=button onclick="redirige();" value="Suivant"><br>
	</div>				
	</body>
</html>


J'explique vite fais ce que je veux faire. 5 boutons radio, l'utilisateur fait un choix, et se retrouve redirigé sur une autre page suivant ce qu'il a choisis.
Alors mon code est surement pas terrible vu que je n'y connais rien... Si quelqu'un pouvait m'expliquer pourquoi FF me dis que "choix n'est pas définit" alors qu'IE le prend très bien, et si possible un peu d'aide sur ce que je dois faire pour résoudre ce problème.


Cordialement, KRz Yamaneko.

3 réponses

KRzYamaneko Messages postés 3 Date d'inscription mardi 26 août 2008 Statut Membre Dernière intervention 27 août 2008
26 août 2008 à 20:26
Personne n'a d'idée? Une piste à creuser? Rien de rien ^^ j'y connais rien mais ça dois pas être si dur que ça si?
0
dreamfeeder Messages postés 253 Date d'inscription samedi 24 novembre 2007 Statut Membre Dernière intervention 25 juillet 2009 54
27 août 2008 à 03:40
bonjour,

cadevrait mieux marcher comme ca:


<html>
<head>
	<script language="javascript">
	function redirige()
	{
	
	var choix=document.getElementsByTagName('input');

		if (choix[0].checked)
		{
		document.location.href="http://krz.blogsite.org/nr.html";
		}
		if (choix[1].checked)
		{
		document.location.href="http://krz.blogsite.org/se.html";
		}
		if (choix[2].checked)
		{
		document.location.href="http://krz.blogsite.org/la.html";
		}
		if (choix[3].checked)
		{
		document.location.href="http://krz.blogsite.org/au.html";
		}
		if (choix[4].checked)
		{
		document.location.href="http://krz.blogsite.org/au.html";
		}
	}
	</script>
</head>
  <body>
  <div style="width:200px;border:solid 1px #000;text-align:center">
  <img src="http://img211.imageshack.us/img211/8266/staarwarlo8.jpg">
  <table>
    <tr>
        <td valign="middle" style="height:200px;">
            <div>
				<table>
				<tr>
				<td><input type="radio" name="choix" value="1">Nouvelle 

République</td>
				</td>
				<tr>
				<td><input type="radio" name="choix" value="2">Séparatistes</td>
				</td>
				<tr>
				<td><input type="radio" name="choix" value="3">Alliance 

Rebelle</td>
				</td>
				<tr>
				<td><input type="radio" name="choix" value="4">L'Ancienne 

République</td>
				</td>
				<tr>
				<td><input type="radio" name="choix" value="5" checked>Autres</td>
				</td>
				</table>
			</div>            
        </td>
    </tr>
	</table>
	<input type="button" onclick="javascript:redirige();" value="Suivant"><br>
	</div>				
</body>
</html>



cordialement, dreamfeeder.
0
KRzYamaneko Messages postés 3 Date d'inscription mardi 26 août 2008 Statut Membre Dernière intervention 27 août 2008
27 août 2008 à 10:03
Yeap merci bien, mais en faite j'ai trouvé aussi en continuant à chercher quelqu'un m'a expliqué qu'en plus pour FF le name n'était reconnu que s'il était mis dans un FORM :) voila des erreur de débutant que je ne ferais plus :)
0