Commit 8be1b1ba authored by root's avatar root

fix error in contact.php and adhesionForm.js

parent c6297e67
......@@ -162,6 +162,21 @@ function prepareDocument() {
}
var choicePeriod = document.getElementById("ancienSelectPeriod").getAttribute("value");
var listOfPeriodOptions = document.getElementsByClassName("optionPeriod");
for (var c = 0; c<listOfPeriodOptions.length; c++){
if (listOfPeriodOptions[c].getAttribute("value") === choicePeriod){
listOfPeriodOptions[c].selected = true;
}
}
}
function secondAction() {
......
......@@ -19,53 +19,64 @@ $errors = array(
"code" => ""
);
$debug_mode = true;
$debug_mode = false;
function tryToEcho($var)
{
if (isset($_POST[$var])) {
function tryToEcho($var){
if (isset($_POST[$var])){
echo $_POST[$var];
}
}
function tryToShowError($var)
{
function tryToSetInputSelect($key,$value){
//fonction utilisée pour définir l'option sélectionnée lorsque l'envoi du formulaire a échoué.
if (isset($_POST[$key])){
if($_POST[$key] == $value){
echo "selected";
}
}
}
function tryToShowError($var){
global $errors;
if (strlen($errors[$var]) > 0) {
if (strlen($errors[$var])>0){
echo "<p class='error'> " . $errors[$var] . "</p>";
}
}
$numberOfErrors = 0;
if (isset($_POST)) {
if (isset($_POST["firstSelection"])) {
if (isset($_POST)){
if (isset($_POST["firstSelection"])){
include "traitementAdhesion.php";
if ($debug_mode) {
if($debug_mode){
echo "<br> début du traitement <br>";
}
$errors = traitement($_POST, $errors);
$errors = traitement($_POST,$errors);
if ($debug_mode) {
if($debug_mode){
echo "<br> fin du traitement <br>";
}
foreach ($errors as $key => $value) {
foreach ($errors as $key => $value){
if ($debug_mode) {
if($debug_mode){
echo $key . " : " . $value . "<br>";
}
if (strlen($value) > 0) {
$numberOfErrors += 1;
if (strlen($value)>0){
$numberOfErrors+=1;
}
}
if ($debug_mode) {
if($debug_mode){
echo "<br> nombre d'erreurs : " . $numberOfErrors . " <br>";
var_dump($errors);
......@@ -74,9 +85,17 @@ if (isset($_POST)) {
}
?>
<html lang="fr">
<head>
<title>Renouvellement d'adhésion</title>
......@@ -175,7 +194,7 @@ function createNameClass($variable)
);
$variable = strtr($variable, $chars);
$variable = strtr($variable,$chars);
return $variable;
}
......@@ -245,24 +264,32 @@ sort($classSelectMenu);
sort($classSelectMenuExtended);
?>
<h1>Formulaire de renouvellement d'adhésion</h1>
<p>
<?php
if ($numberOfErrors == 1) {
if ($numberOfErrors==1){
echo "Une erreur est survenue lors de l'envoi du formulaire. Veuillez vérifier vos informations";
} elseif ($numberOfErrors > 1) {
}
elseif ($numberOfErrors>1){
echo "Plusieurs erreurs sont survenues lors de l'envoi du formulaire. Veuillez vérifier vos informations";
}
?>
</p>
<form action="" method="post">
<p>
<input id="ancienSelectType" type="hidden" name="ancienSelectType" value="<?php tryToEcho("firstSelection")?>">
<input id="ancienSelectSize" type="hidden" name="ancienSelectSize" value="<?php tryToEcho("secondSelection")?>">
<input id="ancienSelectPeriod" type="hidden" name="ancienSelectPeriod" value="<?php tryToEcho("periodeAdhesionCollectivite") ?>">
<label for="firstSelect">Veuillez sélectionner le type de collectivité :</label>
<select id="firstSelect" required="" name="firstSelection">
......@@ -273,7 +300,7 @@ sort($classSelectMenuExtended);
for ($i = 0; $i < count($textsSelectMenuExtended); $i++) {
?>
<option class="optionFirstSelect"
value="<?php echo $classSelectMenuExtended[$i] ?>"><?php echo $textsSelectMenuExtended[$i] ?></option>
value="<?php echo $classSelectMenuExtended[$i] ?>" ><?php echo $textsSelectMenuExtended[$i] ?></option>
<?php
}
......@@ -289,14 +316,12 @@ sort($classSelectMenuExtended);
<div id="formulaireEPCIMutualisant">
<label for="nombreHabitantsEPCI">Nombre d'habitants de l'EPCI :</label>
<input type="number" name="nombreHabitantsEPCI" id="nombreHabitantsEPCI"
value="<?php tryToEcho("nombreHabitantsEPCI"); ?>"><br>
<?php tryToShowError("EPCI com"); ?>
<input type="number" name="nombreHabitantsEPCI" id="nombreHabitantsEPCI" value="<?php tryToEcho("nombreHabitantsEPCI");?>"><br>
<?php tryToShowError("EPCI com");?>
<label for="nombreCommunesMembresEPCI">Nombre de communes membres :</label>
<input type="number" name="nombreCommunesMembresEPCI" id="nombreCommunesMembresEPCI"
value="<?php tryToEcho("nombreCommunesMembresEPCI"); ?>"><br>
<?php tryToShowError("EPCI hab"); ?>
<input type="number" name="nombreCommunesMembresEPCI" id="nombreCommunesMembresEPCI" value="<?php tryToEcho("nombreCommunesMembresEPCI");?>"><br>
<?php tryToShowError("EPCI hab");?>
<input type="button" value="Valider" id="boutonValiderNombresEPCI">
......@@ -394,39 +419,33 @@ sort($classSelectMenuExtended);
<h3>Informations obligatoires :</h3>
<label for="nomCollectivite">Nom de la collectivité :</label>
<input type="text" name="nomCollectivite" id="nomCollectivite" required=""
value="<?php tryToEcho("nomCollectivite"); ?>"><br>
<?php tryToShowError("nom"); ?>
<input type="text" name="nomCollectivite" id="nomCollectivite" required="" value="<?php tryToEcho("nomCollectivite");?>"><br>
<?php tryToShowError("nom");?>
<label for="adresseCollectivite">Adresse :</label>
<input type="text" name="adresseCollectivite" id="adresseCollectivite" required=""
value="<?php tryToEcho("adresseCollectivite"); ?>"><br>
<?php tryToShowError("adresse"); ?>
<input type="text" name="adresseCollectivite" id="adresseCollectivite" required="" value="<?php tryToEcho("adresseCollectivite");?>"><br>
<?php tryToShowError("adresse");?>
<label for="codePostalCollectivite">Code postal :</label>
<input type="text" name="codePostalCollectivite" id="codePostalCollectivite" required=""
value="<?php tryToEcho("codePostalCollectivite"); ?>"><br>
<?php tryToShowError("CP"); ?>
<input type="text" name="codePostalCollectivite" id="codePostalCollectivite" required="" value="<?php tryToEcho("codePostalCollectivite");?>"><br>
<?php tryToShowError("CP");?>
<label for="villeCollectivite">Ville :</label>
<input type="text" name="villeCollectivite" id="villeCollectivite" required=""
value="<?php tryToEcho("villeCollectivite"); ?>"><br>
<?php tryToShowError("ville"); ?>
<input type="text" name="villeCollectivite" id="villeCollectivite" required="" value="<?php tryToEcho("villeCollectivite");?>"><br>
<?php tryToShowError("ville");?>
<label for="telCollectivite">Téléphone :</label>
<input type="tel" name="telCollectivite" id="telCollectivite" required=""
value="<?php tryToEcho("telCollectivite"); ?>"><br>
<?php tryToShowError("tel"); ?>
<input type="tel" name="telCollectivite" id="telCollectivite" required="" value="<?php tryToEcho("telCollectivite");?>"><br>
<?php tryToShowError("tel");?>
<label for="siteCollectivite">Site internet :</label>
<input type="url" name="siteCollectivite" id="siteCollectivite" required=""
value="<?php tryToEcho("siteCollectivite"); ?>"><br>
<?php tryToShowError("site"); ?>
<input type="url" name="siteCollectivite" id="siteCollectivite" required="" value="<?php tryToEcho("siteCollectivite");?>"><br>
<?php tryToShowError("site");?>
<label for="periodeAdhesionCollectivite">Période d'adhésion :</label>
<select name="periodeAdhesionCollectivite" id="periodeAdhesionCollectivite" required="">
<option selected>---</option>
<option class="optionPeriod" value="" selected>---</option>
<?php generateDates(); ?>
</select>
......@@ -434,20 +453,17 @@ sort($classSelectMenuExtended);
<h3>Informations relatives à Chorus Pro</h3>
<label for="siretCollectivite">SIRET :</label>
<input type="number" name="siretCollectivite" id="siretCollectivite" required=""
value="<?php tryToEcho("siretCollectivite"); ?>"><br>
<?php tryToShowError("siret"); ?>
<input type="number" name="siretCollectivite" id="siretCollectivite" required="" value="<?php tryToEcho("siretCollectivite");?>"><br>
<?php tryToShowError("siret");?>
<label for="numeroEngagementCollectivite">N° d'engagement :</label>
<input type="text" name="numeroEngagementCollectivite" id="numeroEngagementCollectivite" required=""
value="<?php tryToEcho("numeroEngagementCollectivite"); ?>"><br>
<?php tryToShowError("numeroEngagement"); ?>
<input type="text" name="numeroEngagementCollectivite" id="numeroEngagementCollectivite" required="" value="<?php tryToEcho("numeroEngagementCollectivite");?>"><br>
<?php tryToShowError("numeroEngagement");?>
<label for="codeCollectivite">Code :</label>
<input type="text" name="codeCollectivite" id="codeCollectivite" required=""
value="<?php tryToEcho("codeCollectivite"); ?>"><br>
<?php tryToShowError("code"); ?>
<input type="text" name="codeCollectivite" id="codeCollectivite" required="" value="<?php tryToEcho("codeCollectivite");?>"><br>
<?php tryToShowError("code");?>
</div>
......
......@@ -56,7 +56,7 @@ function generateDates()
$message = $message . $premiereDate->format("d/m/y");
$message = "<option value='" . $message . "'>" . $message . "</option>";
$message = "<option class='optionPeriod' value='" . $message . "'>" . $message . "</option>";
echo $message;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment