Valider un formulaire sans recharger sa page

Fermé
kyuubi6 - 7 déc. 2011 à 14:05
maka54 Messages postés 698 Date d'inscription mercredi 8 avril 2009 Statut Membre Dernière intervention 4 décembre 2016 - 7 déc. 2011 à 15:46
Bonjour tout le monde,
je viens demander votre aide car ca fait des heures que je me creuse, que je pense avoir la solution mais que je ne sais pas comment faire.
Je vous explique :
J'ai une page "index.php" qui m'affiche un menu et un grand div vide, quand je clique sur mon bouton "encodage" il m'affiche le contenu de ma page encodage dans mon div vide, jusque la j'y arrive.
Ce que j'aimerais c'est que quand j'ai rempli le formulaire d'encodage et que je clique sur enregistrer, il valide mes valeurs sans recharger de page et je pense que c'est possible en ajax.
J'ai fait actuellement un bouton enregistrer qui declanger une fonction qui récupère les valeurs de mes champs puis les envoie a une page php mais je ne sais pas comment passer une valeur de type file.

Voici ma page d'encodage :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="screen" type="text/css" title="interface" href="design.css" />
<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script type="text/javascript" src="encodage.js"></script>
<script type="text/javascript" src="valider.js"></script>
</head>
<body>

<?php
if(isset($_POST['idcachenom']))
{
	$idcachenom = $_POST['idcachenom'] ;
}
else
{
	$idcachenom = "";
}
if(isset($_POST['idcachedoc']))
{
	$idcachedoc = $_POST['idcachedoc'] ;
}
else
{
	$idcachedoc = "";
}
if(isset($_POST['idcacheid']))
{
	$idcacheid = $_POST['idcacheid'] ;
}
else
{
	$idcacheid = "";
}
if(isset($_POST['nom']))
{
	$nom = $_POST['nom'] ;
}
else
{
	$nom = "";
}
if(isset($_POST['prenom']))
{
	$prenom = $_POST['prenom'] ;
}
else
{
	$prenom = "";
}

if(isset($_FILES['photo']) and $_FILES['photo']['name'] != "")
{
	$photo = basename($_FILES['photo']['name']) ;
}

else if(isset($_POST['photocache']) and $_POST['photocache'] != "" )
{
	$photo = $_POST['photocache'];
}
else
{
	$photo = "";
}
if(isset($_POST['sexe']))
{
	if($_POST['sexe'] == 'homme')
	{
		$sexehomme = "checked = 'checked'" ;
		$sexefemme = "";
	}
	else
	{
		$sexehomme = "" ;
		$sexefemme = "checked = 'checked'";
	}
}
else
{
	$sexehomme = "checked = 'checked'" ;
	$sexefemme = "";
}
if(isset($_POST['ddn']))
{
	$ddn = $_POST['ddn'] ;
}
else
{
	$ddn = "";
}
if(isset($_POST['email']))
{
	$email = $_POST['email'] ;
}
else
{
	$email = "";
}
if(isset($_POST['tel']))
{
	$tel = $_POST['tel'] ;
}
else
{
	$tel = "";
}
if(isset($_POST['gsm']))
{
	$gsm = $_POST['gsm'] ;
}
else
{
	$gsm = "";
}
if(isset($_POST['diplome']))
{
	if($_POST['diplome'] == "ceb")
	{
		$selceb = "selected = 'selected'" ;
		$selcesi = "" ;
		$selcess = "" ;
		$selbachelier = "";
		$selautre = "";
	}
	else if($_POST['diplome'] == "cesi")
	{
		$selceb = "" ;
		$selcesi = "selected = 'selected'" ;
		$selcess = "" ;
		$selbachelier = "";
		$selautre = "";
	}
	else if($_POST['diplome'] == "cess")
	{
		$selceb = "" ;
		$selcesi = "" ;
		$selcess = "selected = 'selected'" ;
		$selbachelier = "";
		$selautre = "";
	}	
	else if($_POST['diplome'] == "bachelier")
	{
		$selceb = "" ;
		$selcesi = "" ;
		$selcess = "" ;
		$selbachelier = "selected = 'selected'";
		$selautre = "";
	}
	else 	{
		$selceb = "" ;
		$selcesi = "" ;
		$selcess = "" ;
		$selbachelier = "";
		$selautre = "selected = 'selected'";
	}	
}
else
{
		$selceb = "" ;
		$selcesi = "" ;
		$selcess = "" ;
		$selbachelier = "";
		$selautre = "";
}
if(isset($_POST['adresse']))
{
	$adresse = $_POST['adresse'] ;
}
else
{
	$adresse = "";
}
if(isset($_POST['cp']))
{
	$cp = $_POST['cp'] ;
}
else
{
	$cp = "";
}
if(isset($_POST['ville']))
{
	$ville = $_POST['ville'] ;
}
else
{
	$ville = "";
}
if(isset($_POST['statut']))
{
	if($_POST['statut'] == "cpe")
	{
		$selcpe = "selected = 'selected'" ;
		$selptp = "" ;
		$selape = "" ;
		if(isset($_POST['valcpedeb']) and $_POST['valcpedeb'] != "" )
		{
			$valcpedeb = $_POST['valcpedeb'] ;
			$valcpefin = $_POST['valcpefin'] ;
			$displaycpe = "style='display:table-row;'" ;
			$displayptp = "style='display:none;'" ;
		}
		else
		{
			$valcpedeb = "";
			$valcpefin = "";
			$displaycpe = "style='display:none;'" ;
		}
		if(isset($_POST['plusvalablecpe']) and $_POST['plusvalablecpe'] == "on")
		{
			$checkcpe = "checked = 'checked'" ;
			$checkptp = "";
		}
		else
		{
			$checkcpe = "" ;
			$checkptp = "";
		}
		$valptpdeb = "";
		$valptpfin = "";
		$displayptp = "style='display:none;'" ;
		$checkptp = "";
	}
	else if($_POST['statut'] == "ptp")
	{
		$selcpe = "" ;
		$selptp = "selected = 'selected'" ;
		$selape = "" ;
		if(isset($_POST['valptpdeb']) and $_POST['valptpdeb'] != "" )
		{
			$valptpdeb = $_POST['valptpdeb'] ;
			$valptpfin = $_POST['valptpfin'] ;
			$displayptp = "style='display:table-row;'" ;
			$displaycpe = "style='display:none;'" ;
		}
		else
		{
			$valptpdeb = "";
			$valptpfin = "";
			$displayptp = "style='display:none;'" ;
		}
		if(isset($_POST['plusvalableptp']) and $_POST['plusvalableptp'] == "on")
		{
			$checkptp = "checked = 'checked'" ;
			$checkcpe = "";
		}
		else
		{
			$checkptp = "" ;
			$checkcpe = "";
		}		
		$valcpedeb = "";
		$valcpefin = "";
		$checkcpe = "";
		$displaycpe = "style='display:none;'" ;
	}
	else 
	{
		$selcpe = "" ;
		$selptp = "" ;
		$selape = "selected = 'selected'" ;
		$valcpedeb = "";
		$valcpefin = "";
		$valptpdeb = "";
		$valptpfin = "";	
		$displayptp = "style='display:none;'" ;
		$displaycpe = "style='display:none;'" ;		
		$checkcpe = "";
		$checkptp = "";
	}	
	
}
else
{
		$selcpe = "" ;
		$selape = "" ;
		$selptp = "" ;
		$valcpedeb = "";
		$valcpefin = "";
		$valptpdeb = "";
		$valptpfin = "";
		$displayptp = "style='display:none;'" ;
		$displaycpe = "style='display:none;'" ;		
		$checkcpe = "";
		$checkptp = "";

}
if(isset($_POST['datereception']))
{
	$datereception = $_POST['datereception'] ;
}
else
{
	$datereception = "";
}
if(isset($_POST['reference']))
{
	$reference = $_POST['reference'] ;
}
else
{
	$reference = "";
}
if(isset($_POST['entretien']))
{
	$entretien = $_POST['entretien'] ;
}
else
{
	$entretien = "";
}
if(isset($_POST['engage']))
{
	$engage = $_POST['engage'] ;
}
else
{
	$engage = "";
}
if(isset($_POST['complet']))
{
	if($_POST['complet'] == "oui")
	{
	 $completoui = "checked = 'checked'" ;
	 $completnon = "" ;
	}
	else
	{
	 $completoui = "" ;
	 $completnon = "checked = 'checked'" ;	
	}
}
else
{
	 $completoui = "" ;
	 $completnon = "" ;
}
if(isset($_POST['remarque']))
{
	$remarque = $_POST['remarque'] ;
}
else
{
	$remarque = "";
}
if(isset($_POST['raison']))
{
	$raison = $_POST['raison'] ;
}
else
{
	$raison = "";
}
		if(isset($_POST['dossier']))
		{
			if($_POST['dossier'] == "on")
			{
				$dossier = "checked = 'checked'" ;
				$displayraison = "style='display:inline'";
			}
			else
			{
				$dossier = "" ;
				$displayraison = "style='display:none'";
				$raison = "";
			}
		}
		else
		{
		$dossier = "" ;
		$displayraison = "style='display:none'";
		$raison = "";
		}
		
//documents
if(isset($_FILES['cv']) and $_FILES['cv']['name'] != "")
{
	$cvcache = basename($_FILES['cv']['name']) ;
}

else if(isset($_POST['cvcache']) and $_POST['cvcache'] != "" )
{
	$cvcache = $_POST['cvcache'];
}
else
{
	$cvcache = "";
}

if(isset($_FILES['lm']) and $_FILES['lm']['name'] != "")
{
	$lmcache = basename($_FILES['lm']['name']) ;
}

else if(isset($_POST['lmcache']) and $_POST['lmcache'] != "" )
{
	$lmcache = $_POST['lmcache'];
}
else
{
	$lmcache = "";
}

if(isset($_FILES['scandiplome']) and $_FILES['scandiplome']['name'] != "")
{
	$scandiplomecache = basename($_FILES['scandiplome']['name']) ;
}

else if(isset($_POST['scandiplomecache']) and $_POST['scandiplomecache'] != "" )
{
	$scandiplomecache = $_POST['scandiplomecache'];
}
else
{
	$scandiplomecache = "";
}

if(isset($_FILES['cbm']) and $_FILES['cbm']['name'] != "")
{
	$cbmcache = basename($_FILES['cbm']['name']) ;
}

else if(isset($_POST['cbmcache']) and $_POST['cbmcache'] != "" )
{
	$cbmcache = $_POST['cbmcache'];
}
else
{
	$cbmcache = "";
}
if(isset($_FILES['pdivers']) and $_FILES['pdivers']['name'] != "")
{
	$pdiverscache = basename($_FILES['pdivers']['name']) ;
}

else if(isset($_POST['pdiverscache']) and $_POST['pdiverscache'] != "" )
{
	$pdiverscache = $_POST['pdiverscache'];
}
else
{
	$pdiverscache = "";
}

$valeur_annee = date("Y",time()) ;
$anneeprec1 = $valeur_annee - 1 ;
$anneeprec2 = $valeur_annee - 2 ;
?>
	<form method="post" ENCTYPE="multipart/form-data" action="encodage.php">
		<fieldset>
		<legend>Données personnelles</legend>
		<table border=1 >
		<tr>
			<td class='col1' >Année</td>
			<td class='col2'><select name="valeurannee" id="valeurannee" >
			<option selected="selected" value="<?php echo $valeur_annee ; ?>"><?php echo $valeur_annee ; ?></option>
			<option  value="<?php echo $anneeprec1 ; ?>"><?php echo $anneeprec1 ; ?></option>
			<option  value="<?php echo $anneeprec2 ; ?>"><?php echo $anneeprec2 ; ?></option>
			</select>
			</td>
		</tr>		
		<tr>
			<td class='col1' >Nom</td>
			<td class='col2'><input type="text" onkeyup="lookup2(this.value);" onblur='fill();fill2();' name="nom" id="nom" value="<?php echo $nom ; ?>" tabindex="2" />
			<input type="hidden" id="idcachenom" name="idcachenom" value="<?php echo $idcachenom ; ?>" />
			<input type="hidden" id="idcacheid" name="idcacheid" value="<?php echo $idcacheid ; ?>"  />
			<input type="hidden" id="idcachedoc" name="idcachedoc" value="<?php echo $idcachedoc ; ?>"  /></td>
		</tr>
		<tr>
			<td class='col1'>Prénom</td>
			<td class='col2'><input type="text" onblur='fill();fill2()' id="prenom" name="prenom" value="<?php echo $prenom ; ?>" tabindex="3" /></td>
		</tr>	
		<tr>
			<td class='col1'>Photo</td>
			<td class='col2'><input type="file" id="photo" name="photo"  tabindex="4" />
			<input type="button" value="reset" name="boutonphoto" id="boutonphoto" onclick="effacer('photo');" /><input type="hidden" value="<?php echo $photo ; ?>" id="photocache" name="photocache"/></td>
		</tr>		
		<tr>
			<td class='col1'>Sexe</td>
			<td class='col2'><input type="radio" <?php echo $sexehomme ; ?> name="sexe" value="homme" id="hom" tabindex="5" /> <label for="hom">Homme</label> &nbsp;&nbsp;
			<input type="radio" name="sexe" <?php echo $sexefemme ; ?> value="femme" id="fem" tabindex="5" /> <label for="fem">Femme</label></td>
		</tr>	
		<tr>
			<td class='col1'>Date de naissance</td>
			<td class='col2'><input id="ddn" type="text" onKeyUp='key2(this);' onblur='fill();fill2()' name="ddn" value="<?php echo $ddn ; ?>" tabindex="6" /></td>
		</tr>
		<tr>
			<td class='col1'>Email</td>
			<td class='col2'><input id="email" value="<?php echo $email ; ?>" onblur='fill();fill2()' size="40" type="text" name="email" tabindex="7" /></td>
		</tr>	
		<tr>
			<td class='col1'>Téléphone fixe</td>
			<td class='col2'><input id="tel" onblur='fill();fill2()' onKeyUp='key3(this);' value="<?php echo $tel ; ?>" type="text" name="tel" tabindex="8" /></td>
		</tr>
		<tr>
			<td class='col1'>GSM</td>
			<td class='col2'><input id="gsm"  type="text" onkeyup="key4(this);" value="<?php echo $gsm ; ?>" name="gsm" tabindex="9" onblur='fill();fill2()' /></td>
		</tr>		
		<tr>
			<td class='col1'>Diplome</td>
			<td class='col2'>
			<select name="diplome" tabindex="10" >
			<option value="ceb" <?php echo $selceb ;?> id="ceb" >CEB</option>
			<option value="cesi" <?php echo $selcesi ;?> id="cesi" >CESI</option>
			<option value="cess" <?php echo $selcess ;?> id="cess">CESS</option>
			<option value="bachelier" <?php echo $selbachelier ;?> id="bachelier" >Bachelier</option>
			<option value="autre" <?php echo $selautre ;?> id="autre">Autre</option>
			</select>
			</td>
		</tr>
		<tr>
			<td class='col1'>Adresse</td>
			<td class='col2'><input id="adresse" onblur='fill();fill2()' size="40" value="<?php echo $adresse ; ?>"  type="text" name="adresse" tabindex="11" /></td>
		</tr>	
		
		<tr>
			<td class='col1'>Code Postal</td>
			<td class='col2'><input id="cp"  onkeyup="lookup(this.value);" onblur='fill();fill2();' value="<?php echo $cp ; ?>" type="text" name="cp" tabindex="12" /></td>
		</tr>	
					<div class="suggestionsBox" id="suggestions" style='display: none;'>
				<img src='upArrow.png' style="'position: absolute; left: 50px; top: -10px'" alt="upArrow" />
				<div class="suggestionList" id="autoSuggestionsList">
					&nbsp;
				</div>
			</div>
			<div class="suggestionsBox2" id="suggestions2" style='display: none;'>
				<img src='upArrow.png' style='position: absolute; left: 50px; top: -10px' alt="upArrow" />
				<div class="suggestionList2" id="autoSuggestionsList2">
					&nbsp;
				</div>
			</div>
		<tr>
			<td class='col1'>Ville</td>
			<td class='col2'><input id="ville" onblur='fill();fill2()' value="<?php echo $ville ; ?>"  type="text" name="ville" tabindex="13" /></td>
		</tr>			
		<tr>
			<td class='col1'>Statut</td>
			<td class='col2'><select name="statut" id="statut" tabindex="14" >
			<option value="cpe" <?php echo $selcpe ;?> onclick="affichecpe();" >CPE</option>
			<option value="ptp" <?php echo $selptp ;?> onclick="afficheptp();" >PTP</option>
			<option value="ape" <?php echo $selape ;?> onclick="afficheape();" >APE</option>
			</select>
			</td>
		</tr>
	
		<tr id="valcpe" <?php echo $displaycpe ; ?> >
			<td id="colcpe1" class='col1'>Validité du CPE</td>
			<td id="colcpe2" class='col2'>Du <input type="text" onKeyUp='key2(this);' id="valcpedeb" name="valcpedeb"  value="<?php echo $valcpedeb ; ?>" tabindex="15" /><br/><br/>
			Au <input type="text" name="valcpefin" onKeyUp='key2(this);' id="valcpefin" tabindex="15" value="<?php echo $valcpefin ; ?>" /><br/><br/>
			Plus valable <input type="checkbox" <?php echo $checkcpe ; ?> name="plusvalablecpe" id="plusvalablecpe" />
			</td>
		</tr>
	
		<tr id="valptp" <?php echo $displayptp ; ?>>
			<td class='col1'>Validité du PTP</td>
			<td class='col2'>Du <input type="text" onKeyUp='key2(this);' id="valptpdeb" name="valptpdeb" value="<?php echo $valptpdeb ; ?>"  tabindex="16" /><br/><br/>
			Au <input type="text" name="valptpfin" onKeyUp='key2(this);' id="valptpfin" value="<?php echo $valptpfin ; ?>"  tabindex="16" /><br/><br/>
			Plus valable <input <?php echo $checkptp ; ?> type="checkbox" name="plusvalableptp" id="plusvalableptp" />
			</td>
		</tr>		
		</table>
		</fieldset>
		<fieldset>
		<legend>Données LGCV </legend>
		<table  border=1>
		<tr>
			<td class='col1'>Date de réception</td>
			<td class='col2'><input type="text" name="datereception" value="<?php echo $datereception ; ?>" id="datereception" onKeyUp='key(this);'  tabindex="17" /></td>
		</tr>
		<tr>
			<td class='col1' id="reference">Référence</td>
			<td class='col2'><input type="text" name="reference" value="<?php echo $reference ; ?>" id="nomreference"  tabindex="18" /></td>
		</tr>	
		<tr>
			<td class='col1' >Dossier complet</td>
			<td class='col2'><label for="completoui">Oui </label><input type="radio" <?php echo $completoui ; ?> name="complet" id="completoui" value="oui" tabindex="19" />&nbsp;&nbsp;
			<label for="completnon">Non</label><input type="radio" name="complet" <?php echo $completnon ; ?> id="completnon" value="non" tabindex="19" /></td>
		</tr>	
		<tr>
			<td class='col1' >Entretien effectué le</td>
			<td class='col2'><input type="text" name="entretien" id="entretien" value="<?php echo $entretien ;?>" onkeyup="key2(this);" tabindex="20" /></td>
		</tr>		
		<tr>
			<td class='col1' >Engagé le</td>
			<td class='col2'><input type="text" name="engage" id="engage" value="<?php echo $engage ;?>" onkeyup="key2(this);" tabindex="21" /></td>
		</tr>	
		<tr>
			<td class='col1' >Dossier sans suite ou clotûré</td>
			<td class='col2'><input type="checkbox" <?php echo $dossier ; ?> name="dossier" value="oui" id="dossier" onclick="afficher(this);" tabindex="22" />
			<span id="raison" <?php echo $displayraison ;?>><br/><textarea name="raison" id="raisondossier" cols="40" rows="4" tabindex="23" ><?php echo $raison ;?></textarea></span>
			</td>
		</tr>	
		<tr>
			<td class='col1' >Remarque(s)</td>
			<td class='col2'><textarea name="remarque" cols="30" id="remarque" rows="6" tabindex="24" ><?php echo $remarque ; ?></textarea>
			</td>
		</tr>
		
		</table>
		</fieldset>
		
		<fieldset>
		<legend>Documents </legend>
		<table  border=1>
		<tr>
			<td class='col1'>CV</td>
			<td class='col2'><input type="file" name="cv" id="cv"  tabindex="25" />
			<input type="button" value="reset" name="boutoncv" id="boutoncv" onclick="effacer('cv');" /><input type="hidden" value="<?php echo $cvcache ; ?>" id="cvcache" name="cvcache"/></td>
		</tr>
		<tr>
			<td class='col1'>Lettre de motivation</td>
			<td class='col2'><input type="file" id="lm" name="lm"  tabindex="26" />
			<input type="button" value="reset" name="boutonlm" id="boutonlm" onclick="effacer('lm');" /><input type="hidden" value="<?php echo $lmcache ; ?>" id="lmcache" name="lmcache"/></td>
		</tr>
		<tr>
			<td class='col1'>Diplome</td>
			<td class='col2'><input type="file" name="scandiplome" id="scandiplome"  tabindex="27" />
			<input type="button" value="reset" name="boutonscandiplome" id="boutonscandiplome" onclick="effacer('scandiplome');" /><input type="hidden" value="<?php echo $scandiplomecache ; ?>" id="scandiplomecache" name="scandiplomecache"/></td>
		</tr>
		<tr>
			<td class='col1'>Papier(s) divers</td>
			<td class='col2'><input type="file" id="pdivers" name="pdivers"  tabindex="28" />
			<input type="button" value="reset" name="boutonpdivers" id="boutonpdivers" onclick="effacer('pdivers');" /><input type="hidden" value="<?php echo $pdiverscache ; ?>" id="pdiverscache" name="pdiverscache"/></td>
		</tr>		
		<tr>
			<td class='col1'>Certificat Bonne vie & moeurs</td>
			<td class='col2'><input type="file" id="cbm" name="cbm"  tabindex="29" />
			<input type="button" value="reset" name="boutoncbm" id="boutoncbm" onclick="effacer('cbm');" /><input type="hidden" value="<?php echo $cbmcache ; ?>" id="cbmcache" name="cbmcache"/></td>
		</tr>
		
		</table>
		</fieldset>		
		<fieldset>
		<legend>Validation</legend>
		<table border='1'>
				<tr>
			<td class='col1' colspan="2" ><input type="button" onclick="valider();" id="enregistrer"   name="enregistrer" value="Enregistrer" tabindex="30" />
			<input type="reset" tabindex="31" onclick="if(!confirm('Etes-vous sur de vouloir remettre à zéro ?')) return false;" />
			<input type="button" value="Nouveau formulaire" tabindex="32" onclick="recharger()" /></td>
			

		</tr>
		</table>
		</fieldset>
	</form>
</body>
</html>


Voici ma fonction js
<code >
function valider()
{
var annee = $('#valeurannee').val() ,
nom = $('#nom').val() ,
idcachenom = $('#idcachenom').val() ,
idcachedoc = $('#idcachedoc').val() ,
idcacheid = $('#idcacheid').val() ,
prenom = $('#prenom').val() ,
photo = $('#photo').val() ,
ddn = $('#ddn').val() ,
email = $('#email').val() ,
tel = $('#tel').val() ,
gsm = $('#gsm').val() ,
diplome = $('#diplome').val() ,
adresse = $('#adresse').val() ,
cp = $('#cp').val() ,
ville = $('#ville').val() ,
statut = $('#statut').val() ,
datereception = $('#datereception').val() ,
nomreference = $('#nomreference').val() ,
entretien = $('#entretien').val() ,
engage = $('#engage').val() ,
remarque = $('#remarque').val() ,
cv = $('#cv').val() ,
lm = $('#lm').val() ,
scandiplome = $('#scandiplome').val() ,
pdivers = $('#pdivers').val() ,
cbm = $('#cbm').val();

if(document.getElementById('hom').checked == true)
{
sexe = 'homme' ;
}
if(document.getElementById('fem').checked == true)
{
sexe = 'femme' ;
}
if(document.getElementById('completoui').checked == true)
{
complet = 'oui' ;
}
if(document.getElementById('completnon').checked == true)
{
complet = 'non' ;
}
if(document.getElementById('dossier').checked == true)
{
dossier = 'oui' ;
raison = $('#raisondossier').val();
}
else
{
dossier = 'non' ;
raison = "";
}

if(statut == 'cpe')
{

valstatutdeb = $('#valcpedeb').val() ;
valstatutfin = $('#valcpefin').val() ;
if(document.getElementById('plusvalablecpe').checked == true)
{
plusvalable = "plus valable" ;
}
else
{
plusvalable = "valable" ;
}
}
if(statut == 'ptp')
{
valstatutdeb = $('#valptpdeb').val() ;
valstatutfin = $('#valptpfin').val() ;
if(document.getElementById('plusvalableptp').checked == true)
{
plusvalable = "plus valable" ;
}
else
{
plusvalable = "valable" ;
}
}
if(statut == 'ape')
{
valstatutdeb = "" ;
valstatutfin = "" ;
plusvalable = "" ;
}

/* if($('#mission').val() == "nouvelle" )
{
mission = $('#newmission').val() ;
nouveau = 1 ;
}
else
{
mission = $('#mission').val() ;
nouveau = 0 ;
}
//Error Count
var error_count = 0;



//Blank Comment?
if(debut == '') {
$('#contact_header').after('<p class=error>L\'heure de début n\'a pas été entrée</p>');
error_count += 1;
}
//Blank Comment?
if(fin == '') {
$('#contact_header').after('<p class=error>L\'heure de fin n\'a pas été entrée</p>');
error_count += 1;
}
if(mission == '' ) {
$('#contact_header').after('<p class=error>Vous n\'avez pas choisit de mission</p>');
error_count += 1;
}
if(mission == 'choisir' ) {
$('#contact_header').after('<p class=error>Vous n\'avez pas choisit de mission</p>');
error_count += 1;
}
//No Errors?

if(error_count === 0) {

$.ajax({
type: "post",
url: "traitement.php",
data: "mission=" + mission + "&debut=" + debut + "&fin=" + fin + "&jour=" + time + "&idsteward=" + idsteward + "&nouv=" + nouveau,
error: function() {
$('.error').hide();
$('#sendError').slideDown('slow');
},
success: function () {
$('.error').hide();
$('.success').slideDown('slow');
$('form#contactForm').fadeOut('slow');

$.ajax({
type: "get",
url: "donnees.php",
data: "time=" + time,

success: function (msg) {
$('#'+jour).html(msg);
//je mets a jour les missions
$.ajax({
type: "get",
url: "choixmission.php",

success: function (msg) {
$('#choixmission').html(msg);
}

});

}

});
}

});

*/
/* }
else
{
alert('vous avez oublié des truc');
} */
}
</code>
Merci beaucoup de votre aide



A voir également:

1 réponse

maka54 Messages postés 698 Date d'inscription mercredi 8 avril 2009 Statut Membre Dernière intervention 4 décembre 2016 80
7 déc. 2011 à 15:46
tu ne peux pas envoyer un fichier en ajax

par contre il y a une solution en utilisant une iframe

<iframe id="iframeForm" style="display:none;"></iframe>

<form action="page.php" target="iframeForm">
[...]
</form>
0