Forums

Chronoform javascript form doesn't work

Eliane 11 Sep, 2009
Hi,

I use Chronoform 3.1 RC5.5 and I have a problem to use the form javascript. When I submit my form there is a blank page anything else (http://www.ah-fitness.fr/index.php?option=com_content&view=article&id=130&Itemid=118). It should appaer a popup with the response.

Please could you help me to understand where is the problem.

Below here is the code form.

Many thanks.

Brgds.
Eliane.



My form HTML is :

<p align="center"><font size="4"><strong>Quelle(s) activité(s)
    aimeriez-vous pratiquer ? </strong></font></p>
    <ul type="disc">
        <li><p align="center"><font size="3"><strong>Cours type
            CARDIO :</strong> T.B.C. </font><input
            type="checkbox" name="CARDIO" value="1"> HILO <input
            type="checkbox" name="CARDIO" value="2"> STEP <input
            type="checkbox" name="CARDIO" value="3"> </p>
        </li>
    </ul>
    <ul type="disc">
        <li><p align="center"><font size="3"><strong>Cours de
            type GYM : </strong></font>GYM <input
            type="checkbox" name="GYM" value="10"> GYM POWER <input
            type="checkbox" name="GYM" value="11"> ABDO / FESSIER
            <input type="checkbox" name="GYM" value="12"> PILATES
            <input type="checkbox" name="GYM" value="13">
            STRETCHING <input type="checkbox" name="GYM"
            value="14"></p>
        </li>
    </ul>
    <p align="center"> </p>
    <hr>
    <p align="center"><font size="4"><strong>A quel rythme
    voulez-vous pratiquer votre Fitness : </strong></font></p>
    <p align="center">plusieurs jours par semaine<input
    type="radio" checked name="Rythme" value="1"> Une seule
    journée et toujours la même <input type="radio"
    name="Rythme" value="2"> Une seule journée et rarement la
    même <input type="radio" name="Rythme" value="3"></p>
    <p align="left"> </p>
    <p align="center"><input type="submit"
    name="demander le forfait adapté"
    value="demander le forfait adapté"
     </p>


My form javascript is :

f=document.ChronoContact_Choixdufortait;

function RechercheForfait(VerifForm)      {
		message1 = "Veuillez saisir au moins une activité";
		message2 = "Forfait GYM";
		message3 = "Forfait LIBERTE";
		message4 = "Forfait JOURNEE - veuillez choisir votre soirée en fonction de votre agenda";
		message5 = "Forfait INTEGRAL";
		message6 = "Forfait ADOS";
		message7 = "test message défaut";
		
<!--aucune saisie     ANOMALIE -->			
		if  (VerifForm.CARDIO.value == "")
		and (VerifForm.GYM.value    == "")
			 VerifForm.CARDIO.focus();
			 alert(message1);
			 return (false);
			
<!-- gestion des réponses et choix du résultat de la demande -->			  
		switch (Rythme) 			{
			case 1 : if  (VerifForm.CARDIO.value == "") {
						 VerifForm.CARDIO.focus();
					 	 alert(message2);
			 		     return (true);	
					}else{ alert(message5);                        
					  }	; return (true);	
			case 2 : if  (VerifForm.CARDIO.value == "") {
						 VerifForm.CARDIO.focus();
					 	 alert(message2);
			 		     return (true);	
					}else{ alert(message4);
			 		 }	; return (true);	
			case 3 : if  (VerifForm.CARDIO.value == "") {
						 VerifForm.CARDIO.focus();
					 	 alert(message2);
			 		     return (true);	
					}else{ alert(message3);
					 }	; return (true);	
			default:  alert(message7);
			 		     return (true);	  
		}	}


My form attachment tag is :
onSubmit=RechercheForfait(VerifForm)
GreyHead 13 Sep, 2009
Hi Eliane,

There is a JavaScript Error on submission saying, I think, that 'VerifForm is not defined'.

Bob
Eliane 01 Nov, 2009
Hi,

Following my mails below I have checked my form again. But it doesn't work. I have asked the question on the forum but anyone gave me any response.

I send again my code below.
My javascript code is
function RechercheForfait(VerifForm){
var form=document.ChronoContact_Choixdufortait;
		message1 = "Veuillez saisir au moins une activité";
		message2 = "Forfait GYM";
		message3 = "Forfait LIBERTE";
		message4 = "Forfait JOURNEE - veuillez choisir votre soirée en fonction de votre agenda";
		message5 = "Forfait INTEGRAL";
		message6 = "Forfait ADOS";
		message7 = "test message défaut";
		}
<!--aucune saisie     ANOMALIE -->
{var form=document.ChronoContact_Choixdufortait;			
		if  (VerifForm.CARDIO.value == "")
		and (VerifForm.GYM.value    == "")
			 VerifForm.CARDIO.focus();
			 alert(message1);
			 return (false);
			}
<!-- gestion des réponses et choix du résultat de la demande -->	
{var form=document.ChronoContact_Choixdufortait;		  
		switch (Rythme) 			{
			case 1 : if  (VerifForm.CARDIO.value == "") {
						 VerifForm.CARDIO.focus();
					 	 alert(message2);
			 		     return (true);	
					}else{ alert(message5);                        
					  }	; return (true);	
			case 2 : if  (VerifForm.CARDIO.value == "") {
						 VerifForm.CARDIO.focus();
					 	 alert(message2);
			 		     return (true);	
					}else{ alert(message4);
			 		 }	; return (true);	
			case 3 : if  (VerifForm.CARDIO.value == "") {
						 VerifForm.CARDIO.focus();
					 	 alert(message2);
			 		     return (true);	
					}else{ alert(message3);
					 }	; return (true);	
			default:  alert(message7);
			 		     return (true);	  
		}	}

My html code is :
<div>
<p align="center"><font size="4"><strong>Quelle(s) activité(s) 
aimeriez-vous pratiquer ? </strong></font></p> 
<ul type="disc"> 
<li><p align="center"><font size="3"><strong>Cours type 
CARDIO :</strong> T.B.C. </font> 
<input type="checkbox" name="CARDIO" value="1"> 
HILO 
<input type="checkbox" name="CARDIO" value="2"> 
STEP 
<input type="checkbox" name="CARDIO" value="3"></p> 
</li> 
</ul> 
<ul type="disc"> 
<li><p align="center"><font size="3"><strong>Cours de 
type GYM : </strong></font>GYM 
<input type="checkbox" name="GYM" value="10"> 
GYM POWER 
<input type="checkbox" name="GYM" value="11"> 
ABDO / FESSIER 
<input type="checkbox" name="GYM" value="12"> 
PILATES 
<input type="checkbox" name="GYM" value="13"> 
STRETCHING 
<input type="checkbox" name="GYM" value="14"></p> 
</li> 
</ul> 
<p align="center"> </p> 
<hr> 
<p align="center"><font size="4"><strong>A quel rythme 
voulez-vous pratiquer votre Fitness : </strong></font></p> 
<p align="center">plusieurs jours par semaine<input 
type="radio" checked_name="Rythme" value="1"> Une seule 
journée et toujours la même <input type="radio" 
name="Rythme" value="2"> Une seule journée et rarement la 
même <input type="radio" name="Rythme" value="3"></p> 
<p align="left"> </p> 
<p align="center"><input type="submit" 
name="demander le forfait adapté" 
value="demander le forfait adapté"> 
</p> 

</div> 

My form tag attachment is :
on submit=RechercheForfait(VerifForm)

Please is there someone help me to understand the problem.

Many thanks.

Eliane
nml375 01 Nov, 2009
Hi Elaine,
First thing, I'm not sure why you have a html-style comment in your javascript.
Secondly, either your brackets {} are out of order, or you are missing some function declarations.
Thirdly, your conditional is improperly formatted.

Checking your first post however, looks better. However, there you state that you've got "onsubmit=RechercheForfait(VerifForm)" as Form tag attachment, and this is where you get your error..
You could try something like this instead:
"onsubmit=RechercheForfait(this)"

I also took the liberty of cleaning/formatting/indenting your code properly, along with fixing the above mentioned issues..
function RechercheForfait(VerifForm) {
  var form=document.ChronoContact_Choixdufortait;
  message1 = "Veuillez saisir au moins une activité";
  message2 = "Forfait GYM";
  message3 = "Forfait LIBERTE";
  message4 = "Forfait JOURNEE - veuillez choisir votre soirée en fonction de votre agenda";
  message5 = "Forfait INTEGRAL";
  message6 = "Forfait ADOS";
  message7 = "test message défaut";

  if (VerifForm.CARDIO.value == "" && VerifForm.GYM.value == "")
  {
    VerifForm.CARDIO.focus();
    alert(message1);
    return (false);
  }

  switch (Rythme)
  {
   case 1:
    if  (VerifForm.CARDIO.value == "") {
      VerifForm.CARDIO.focus();
      alert(message2);
      return (true);
    } else
    {
      alert(message5);
    }
    return (true);

   case 2:
    if (VerifForm.CARDIO.value == "") {
      VerifForm.CARDIO.focus();
      alert(message2);
      return (true);
    } else
    {
      alert(message4);
    }
    return (true);

   case 3:
    if  (VerifForm.CARDIO.value == "") {
      VerifForm.CARDIO.focus();
      alert(message2);
      return (true);
    } else
    {
      alert(message3);
    }
    return (true);
   default:
    alert(message7);
    return (true);
  }
}


Edit: fixed an error in the javascript. Should'nt use "and", but "&&" for the logical and operation.
/Fredrik
Max_admin 02 Nov, 2009
Hi Eliane,

just to clarify, if you want this in your form tag attachment :

"onsubmit=RechercheForfait(this)"


then you should actually write in the box this:

onsubmit="RechercheForfait(this)"


it supposed that you have a return before the function name but it depends on what you are doing!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Eliane 02 Nov, 2009
Hi,

Many thanks for your feedback, I have made all corrections but unfortunately it still doesn't work.

You asked :

it supposed that you have a return before the function name but it depends on what you are doing!



I want to have a popup window which open with the result form.

BRgds.

Eliane
nml375 02 Nov, 2009
Hi Elaine,
It seems there was an error in your script that I missed; you can't use the word "and" for the logical and operation - you'll have to use "&&" instead. I've updated my previous post to correct this.

/Fredrik
This topic is locked and no more replies can be posted.