code works on IE but not on MOZILLA

Discussion in 'Javascript' started by Pascal, Aug 13, 2009.

  1. Pascal

    Pascal Guest

    Hello
    why this code works on IE but not on MOZILLA,?
    thanks
    pascal
    <script type="text/javascript">
    //<![CDATA[
    <!--
    function verif_formulaire()
    {
    if(document.formulaire.classe_actuelle.value == "?") {
    alert("Veuillez choisir votre classe actuelle!");
    document.formulaire.classe_actuelle.focus();
    return false;
    }

    // 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;
    }

    if(document.formulaire.prenom.value == "") {
    alert("Veuillez entrer votre prenom!");
    document.formulaire.prenom.focus();
    return false;
    }
    if(document.formulaire.nom.value == "") {
    alert("Veuillez entrer votre nom!");
    document.formulaire.nom.focus();
    return false;
    }

    // validate sexe
    myOption = -1;
    for (i=formulaire.sexe.length-1; i > -1; i--) {
    if (formulaire.sexe.checked) {
    myOption = i; i = -1;
    }
    }
    if (myOption == -1) {
    alert("Tu dois choisir un sexe");
    return false;
    }

    if(document.formulaire.classe.value == "?") {
    alert("Veuillez choisir la classe d'origine!");
    document.formulaire.classe.focus();
    return false;
    }

    //Choix de la page
    if(document.formulaire.matiere[0].checked == true)
    {
    document.formulaire.action ="voc/index.php";
    }
    else
    if(document.formulaire.matiere[1].checked == true)
    {
    document.formulaire.action ="conj/index.php";
    }
    else
    if(document.formulaire.matiere[2].checked == true)
    {
    document.formulaire.action ="gram/index.php";
    }
    else
    if(document.formulaire.matiere[3].checked == true)
    {
    document.formulaire.action ="orth/index.php";
    }
    else
    if(document.formulaire.matiere[4].checked == true)
    {
    document.formulaire.action ="lect/index.php";
    }
    return true;


    }
    //-->
    //]]>
    </script>


    --
    http://www.scalpa.info
    http://scalpa98.blogspot.com/
    http://scalpa-production.blogspot.com/
    Pascal, Aug 13, 2009
    #1
    1. Advertising

  2. Pascal

    Evertjan. Guest

    Pascal wrote on 13 aug 2009 in comp.lang.javascript:

    > Hello
    > why this code works on IE but not on MOZILLA,?
    > thanks
    > pascal
    > <script type="text/javascript">
    > //<![CDATA[
    > <!--
    > function verif_formulaire()
    > {
    > if(document.formulaire.classe_actuelle.value == "?") {
    > alert("Veuillez choisir votre classe actuelle!");
    > document.formulaire.classe_actuelle.focus();


    document.formulaire would only sometimes work in IE.

    try if this is about a <form>:

    document.forms['formulaire'].elements['classe_actuelle'].focus();


    > return false;
    > }
    >
    > // validate matiere
    > myOption = -1;
    > for (i=formulaire.matiere.length-1; i > -1; i--) {


    formulaire is undefined, except sometimes in IE:

    document.forms['formulaire'].elements['....


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 13, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manuel
    Replies:
    3
    Views:
    737
    =?Utf-8?B?RXJpYyBXaWxzb24=?=
    Jan 5, 2006
  2. peshrad
    Replies:
    1
    Views:
    151
    Chris
    Jul 22, 2004
  3. Madhusudan Singh
    Replies:
    0
    Views:
    65
    Madhusudan Singh
    Jul 18, 2003
  4. Keegan Alex

    Code works in IE but not Netscape/Mozilla

    Keegan Alex, Jul 30, 2003, in forum: Javascript
    Replies:
    1
    Views:
    105
    Janwillem Borleffs
    Jul 30, 2003
  5. Patrick
    Replies:
    2
    Views:
    133
    Patrick
    Aug 26, 2003
Loading...

Share This Page