P
Pascal
hello i am new to javascript and I am trying to send the visitor of my page
to another depending what he feeds in the form but there is an error i can't
figure ! Can you help me to find it please?
the error says line 27 carac 3 voc is undefined and if I put 0 instead of
voc, it works ! Why ? The value of this radio button is voc ! not 0
thanks
pascal
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
<!--
function verif_formulaire()
{
// validate matiere
myOption = -1;
for (i=formulaire.matiere.length-1; i > -1; i--) {
if (formulaire.matiere.checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("Tu dois choisir une matière");
return false;
}
//Choix de la page
if(document.formulaire.matiere[voc].checked == true)
{
document.formulaire.action ="voc/index.php";
}
else
if(document.formulaire.matiere[conj].checked == true)
{
document.formulaire.action ="conj/index.php";
}
else
if(document.formulaire.matiere[gram].checked == true)
{
document.formulaire.action ="gram/index.php";
}
else
if(document.formulaire.matiere[orth].checked == true)
{
document.formulaire.action ="orth/index.php";
}
else
if(document.formulaire.matiere[lect].checked == true)
{
document.formulaire.action ="lect/index.php";
}
return true;
}
</script>
<form name="formulaire" onsubmit="return verif_formulaire()" id="formulaire"
method="post" enctype="multipart/form-data">
<fieldset><legend>ETAPE N°2</legend>
Choisir la matière.<br />
<input id="voc" name="matiere" type="radio" value="voc" />Vocabulaire
<input id="conj" name="matiere" type="radio" value="conj" />Conjugaison
<input id="gram" name="matiere" type="radio" value="gram" />Grammaire
<input id="orth" name="matiere" type="radio" value="orth" />Orthographe
<input id="lect" name="matiere" type="radio" value="lect" />Lecture
</fieldset>
<input type="submit" value="S'inscrire">
</form>
</body>
</html>
to another depending what he feeds in the form but there is an error i can't
figure ! Can you help me to find it please?
the error says line 27 carac 3 voc is undefined and if I put 0 instead of
voc, it works ! Why ? The value of this radio button is voc ! not 0
thanks
pascal
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
<!--
function verif_formulaire()
{
// validate matiere
myOption = -1;
for (i=formulaire.matiere.length-1; i > -1; i--) {
if (formulaire.matiere.checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("Tu dois choisir une matière");
return false;
}
//Choix de la page
if(document.formulaire.matiere[voc].checked == true)
{
document.formulaire.action ="voc/index.php";
}
else
if(document.formulaire.matiere[conj].checked == true)
{
document.formulaire.action ="conj/index.php";
}
else
if(document.formulaire.matiere[gram].checked == true)
{
document.formulaire.action ="gram/index.php";
}
else
if(document.formulaire.matiere[orth].checked == true)
{
document.formulaire.action ="orth/index.php";
}
else
if(document.formulaire.matiere[lect].checked == true)
{
document.formulaire.action ="lect/index.php";
}
return true;
}
</script>
<form name="formulaire" onsubmit="return verif_formulaire()" id="formulaire"
method="post" enctype="multipart/form-data">
<fieldset><legend>ETAPE N°2</legend>
Choisir la matière.<br />
<input id="voc" name="matiere" type="radio" value="voc" />Vocabulaire
<input id="conj" name="matiere" type="radio" value="conj" />Conjugaison
<input id="gram" name="matiere" type="radio" value="gram" />Grammaire
<input id="orth" name="matiere" type="radio" value="orth" />Orthographe
<input id="lect" name="matiere" type="radio" value="lect" />Lecture
</fieldset>
<input type="submit" value="S'inscrire">
</form>
</body>
</html>