11521 sujets

JavaScript, DOM et API Web HTML5

Bonjour,

J'ai créé un formulaire de devis en ligne pour un camping. Je ne sais pas ce qu'il s'est passé mais celui ci ne fonctionne plus. Je m'arrache les cheveux depuis plusieurs mois... Pouvez-vous m'aider svp ? Merci par avance pour votre aide

code :

<html>
<head>
<title>devis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est obligatoire.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body bgcolor="#FFFFCC" link="#FBC900" vlink="#FBC900" alink="#FBC900" topmargin="5">
<form action="<?php echo $PHP_SELF; ?>" method="post" name="form1" onSubmit="MM_validateForm('adulte','','R','nuit','','R');MM_validateForm('adulte','','NisNum','enfant','','NisNum','voiture','','NisNum','moto','','NisNum','camping_car','','NisNum','quad','','NisNum','bateau','','NisNum','tracteur','','NisNum','chien','','NisNum','nuit','','NisNum');return document.MM_returnValue" >
<table width="801" height="557" border="2" align="center" cellspacing="1" bordercolor="#003399">
<tr>
<td width="795" height="553" valign="top" bgcolor="#FFFFFF">
<table width="701" border="0" align="center" cellspacing="2" bgcolor="#FFFFFF">
<tr>
<td width="478" height="135">
<div align="left"><img src="images/calculez-le-prix2.jpg" width="400" height="133"></div></td>
<td width="213" valign="bottom">
<div align="center">
<table width="161" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="161" height="17"><font color="#509FF8" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>&gt;
Basse saison</strong></font></td>
</tr>
<tr>
<td height="32"><font color="#FFCC00" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>&gt;
<a href="devis-h-saison.php" target="_self"><u>Haute saison</u></a></strong></font></td>
</tr>
</table>
</div></td>
</tr>
</table>
<table width="709" border="0" align="center" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="705" height="383" valign="top">
<table width="689" border="0" align="center" cellspacing="0">
<tr>
<td height="3" colspan="2"><img src="images/trai-bleu.gif" width="650" height="1"></td>
</tr>
<tr>
<td height="35" colspan="2">
<table width="665" height="33" border="0" cellspacing="0">
<tr>
<td width="163" height="33"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Type
d'emplacement : </strong></font></td>
<td width="245">
<div align="left">
<table width="247" height="20" border="0" cellspacing="0">
<tr>
<td width="26"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="electricite" type="radio" value="avec" checked>
</font></td>
<td width="30"><font color="#333366"><img src="images/picto-electr.gif" width="21" height="25"></font></td>
<td width="185"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Avec
&eacute;lectricit&eacute; (8,50&euro;)</font></td>
</tr>
</table>
</div></td>
<td width="251"> <table width="243" height="20" border="0" cellspacing="0">
<tr>
<td width="23"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input type="radio" name="electricite" value="sans">
</font></td>
<td width="27"><font color="#333366"><img src="images/picto-sans-electr.gif" width="21" height="25"></font></td>
<td width="187"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Sans
&eacute;lectricit&eacute; (4,00&euro;)</font></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="26" colspan="2"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Nombre
de participants au s&eacute;jour :</strong></font></td>
</tr>
<tr>
<td height="26" colspan="2"> <table width="523" border="0" cellspacing="0">
<tr>
<td width="424"><table width="408" border="0" cellspacing="0">
<tr>
<td width="42"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="images/picto-adulte.gif" width="25" height="30"></font></td>
<td width="362"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Nombre
d'adultes (4,30 &euro; &agrave; partir de 12 ans)
:</font></td>
</tr>
</table></td>
<td width="95"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="adulte" type="text" value="<?php echo $adulte; ?>" size="2" maxlength="2">
</font></td>
</tr>
</table></td>
</tr>
<tr>
<td height="26" colspan="2"> <table width="523" border="0" cellspacing="0">
<tr>
<td width="424"><table width="388" border="0" cellspacing="0">
<tr>
<td width="42"><font color="#333366"><img src="images/picto-enfants.gif" width="25" height="23"></font></td>
<td width="342"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Nombre
d'enfants (2,40 &euro; &agrave; partir de 6 ans)
: </font></td>
</tr>
</table></td>
<td width="95"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="enfant" type="text" value="<?php echo $enfant; ?>" size="2" maxlength="2">
</font></td>
</tr>
</table></td>
</tr>
<tr>
<td height="41" colspan="2" valign="top"><table width="523" border="0" cellspacing="0">
<tr>
<td width="425"> <table width="388" border="0" cellspacing="0">
<tr>
<td width="41"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="images/picto-chien.gif" width="26" height="25"></font></td>
<td width="343"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Nombre
d'animaux (2,50 &euro;) :</font></td>
</tr>
</table></td>
<td width="94"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="chien" type="text" value="<?php echo $chien; ?>" size="1" maxlength="1">
</font></td>
</tr>
</table></td>
</tr>
<tr>
<td height="111" colspan="2"> <table width="678" border="0" align="left" cellspacing="0">
<tr>
<td><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>V&eacute;hicule(s)
: </strong></font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="306"><div align="left">
<table width="293" border="0" cellspacing="0">
<tr>
<td width="69"><font color="#333366"><img src="images/picto_voiture1.gif" width="45" height="20"></font></td>
<td width="220"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Voiture
(1,70 &euro;) : </font></td>
</tr>
</table>
</div></td>
<td width="12"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="voiture" type="text" value="<?php echo $voiture; ?>" size="1" maxlength="1">
</font></td>
<td width="310"><div align="left">
<table width="229" border="0" cellspacing="0">
<tr>
<td width="65" height="30"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="images/picto-moto1.gif" width="40" height="23"></font></td>
<td width="160"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Moto
(0,90 &euro;) : </font></td>
</tr>
</table>
</div></td>
<td width="42"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="moto" type="text" value="<?php echo $moto; ?>" size="1" maxlength="1">
</font></td>
</tr>
<tr>
<td height="31"> <div align="left">
<table width="296" border="0" cellspacing="0">
<tr>
<td width="68"><font color="#333366"><img src="images/picto_campingcar2.gif" width="42" height="24"></font></td>
<td width="224"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Camping-car
(1,70 &euro;) :</font></td>
</tr>
</table>
</div></td>
<td><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="camping_car" type="text" value="<?php echo $camping_car; ?>" size="1" maxlength="1">
</font></td>
<td><div align="left">
<table width="230" border="0" cellspacing="0">
<tr>
<td width="65"><div align="left"><font color="#333366"><img src="images/picto_quad1.gif" width="42" height="27"></font></div></td>
<td width="161"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Quad
(0,90 &euro;) :</font></td>
</tr>
</table>
</div></td>
<td><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="quad" type="text" value="<?php echo $quad; ?>" size="1" maxlength="1">
</font></td>
</tr>
<tr>
<td height="30"> <div align="left">
<table width="296" border="0" cellspacing="0">
<tr>
<td width="68"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="images/picto-bateau.gif" width="57" height="25"></font></td>
<td width="224"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Bateau
sur remorque (1,70&euro;) : </font></td>
</tr>
</table>
</div></td>
<td><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="bateau1" type="text" value="<?php echo $bateau1; ?>" size="1" maxlength="1">
</font></td>
<td height="30"> <div align="left">
<table width="297" border="0" cellspacing="0">
<tr>
<td width="66"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="images/picto-bateau.gif" width="57" height="25"></font></td>
<td width="227"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Bateau
sans remorque (0,90 &euro;) : </font></td>
</tr>
</table>
</div></td>
<td><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="bateau2" type="text" value="<?php echo $bateau2; ?>" size="1" maxlength="1">
</font></td>
</tr>
<tr>
<td height="29">
<div align="left">
<table width="205" border="0" cellspacing="0">
<tr>
<td width="68"><div align="left"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="images/picto-tracteur.gif" width="36" height="25"></font></div></td>
<td width="133"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Tracteur
(0,90 &euro;) :</font></td>
</tr>
</table>
</div></td>
<td><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="tracteur" type="text" value="<?php echo $tracteur; ?>" size="1" maxlength="1">
</font></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td height="39" colspan="2"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><br>
Dur&eacute;e du s&eacute;jour :<br>
</strong>Exemple de calcul : vous arrivez le lundi dans la
journ&eacute;e et vous repartez le mercredi, vous passez donc
les nuits du lundi soir et du mardi soir au camping, vous
devez donc compter 2 nuit&eacute;es.</font></td>
</tr>
<tr>
<td width="328" height="31"> <table width="286" border="0" cellspacing="0">
<tr>
<td width="239" height="29">
<table width="193" border="0" cellspacing="0">
<tr>
<td width="68"><font color="#333366"><img src="images/picto-nuit.gif" width="34" height="25"></font></td>
<td width="121"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Nombre
de nuit&eacute;s</font></td>
</tr>
</table></td>
<td width="43"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="nuit" type="text" value="<?php echo $nuit; ?>" size="2" maxlength="2">
</font></td>
</tr>
</table></td>
<td width="357"><font color="#333366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><em>La
taxe de s&eacute;jour est de 0,44 &euro; pour<br>
la p&eacute;riode du 1er juin au 30 septembre inclus.</em></strong></font></td>
</tr>
<tr>
<td height="18" colspan="2"><div align="left">
<table width="651" height="16" border="0" cellspacing="0">
<tr>
<td width="557" height="16">
<div align="left"><font color="#333366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>ATTENTION
: Si vous s&eacute;journez sur la p&eacute;riode
du 1er juin au 30 septembre, cochez la case suivante</strong></font></div></td>
<td width="90"> <div align="left"><font color="#333366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input type="checkbox" name="taxe" value="oui">
</font></div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td height="30" colspan="2"><div align="center">
<table width="145" border="0" cellspacing="0">
<tr>
<td width="91" height="28"> <div align="center"> <font color="#333366">
<input type="reset" name="Submit2" value="Reset">
</font></div></td>
<td width="75"><font color="#333366">
<input type="submit" name="Submit" value="Résultat">
</font></td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<table width="669" border="1" align="center" cellspacing="0" bordercolor="#0066FF" bgcolor="#FFFFFF">
<tr>
<td width="626" height="27">
<div align="center"><strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<?php
if (isset($electricite) && $electricite=="avec") {
$elec=8.50;
}
if (isset($electricite) && $electricite=="sans") {
$elec=4.00;
}
$ad=$adulte*4.30;
$enf=$enfant*2.40;
$voit=$voiture*1.70;
$camp=$camping_car*1.70;
$batr=$bateau1*1.66;
$bat=$bateau2*0.90;
$mot=$moto*0.90;
$q=$quad*0.90;
$trac=$tracteur*0.90;
$ch=$chien*2.50;
if (isset($taxe) && $taxe=="oui") {
$taxe=0.44;
}
$t_taxe=$taxe*$adulte;
$resultat=$elec+$ad+$enf+$voit+$camp+$batr+$bat+$mot+$q+$trac+$ch;
$total=$resultat*$nuit+$t_taxe*$nuit;
echo "Le coût par nuit est de $resultat € et le coût total de votre séjour est de $total €";
?>
</font></strong> </div></td>
</tr>
</table>
<br>
</td>
</tr>
</table>
</form>
</body>
</html>
[/i][/i]
Salut

Pour les gens qui voudraient t'aider pourrais tu mettre ton code dans des balises séparées ? JS d'un côté, HTML de l'autre et expliquer le fonctionnement de ton script et en quoi il ne fonctionne plus ?

Autrement on te peux rien faire pour toi Smiley ohwell