Skip to content
Snippets Groups Projects
Commit 4e272a87 authored by nicrausaz's avatar nicrausaz
Browse files

fix dyn inputs

parent e7a8123d
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,7 @@ function initDateChecker() { ...@@ -51,7 +51,7 @@ function initDateChecker() {
} }
function addChildren(parentId, maxItems, childTemplate, addButtonId) { function addChildren(parentId, maxItems, childTemplate, addButtonId) {
var i = $(parentId + ' > tbody').children().length + 1; var i = $(parentId + ' > tbody').children().length;
if (i < maxItems) { if (i < maxItems) {
var fullTemplate = childTemplate.replace(/\{(.*?)\}/g, i); var fullTemplate = childTemplate.replace(/\{(.*?)\}/g, i);
$(parentId).append(fullTemplate); $(parentId).append(fullTemplate);
......
<?php
$trainings = getTrainingById($pdo, $current_post['applicant_id']);
?>
<table id="stages">
<tr>
<th>Métier</th>
<th>Entreprise</th>
</tr>
<?php foreach ($trainings as $key => $training) { $i = $key + 1; ?>
<tr>
<td>
<input type="text" class="form-control" name="activiteStage<?php echo $i ?>" placeholder="Métier" value="<?= $training['training_job'] ?>" >
</td>
<td>
<input type="text" class="form-control" name="entrepriseStage<?php echo $i ?>" placeholder="Entreprise" value="<?= $training['training_company'] ?>" >
</td>
</tr>
<?php } ?>
</table>
<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addStage">Ajouter une ligne</button>
\ No newline at end of file
<table id="activites"> <table id="activites">
<tr>
<th>Employeur</th>
<th>Lieu</th>
<th>Activité</th>
<th>Années</th>
</tr>
<tr> <tr>
<td> <td>
<label for="employeurPro1">Employeur</label>
<input type="text" class="form-control" name="employeurPro1" placeholder="Employeur" value="<?php echo $_SESSION['postedForm']['employeurPro1'] != '' ? $_SESSION['postedForm']['employeurPro1'] : ''; ?>"/> <input type="text" class="form-control" name="employeurPro1" placeholder="Employeur" value="<?php echo $_SESSION['postedForm']['employeurPro1'] != '' ? $_SESSION['postedForm']['employeurPro1'] : ''; ?>"/>
</td> </td>
<td> <td>
<label for="lieuPro1">Lieu</label>
<input type="text" class="form-control" name="lieuPro1" placeholder="Lieu" value="<?php echo $_SESSION['postedForm']['lieuPro1'] != '' ? $_SESSION['postedForm']['lieuPro1'] : ''; ?>"/> <input type="text" class="form-control" name="lieuPro1" placeholder="Lieu" value="<?php echo $_SESSION['postedForm']['lieuPro1'] != '' ? $_SESSION['postedForm']['lieuPro1'] : ''; ?>"/>
</td> </td>
<td> <td>
<label for="activitePro1">Activité</label>
<input type="text" class="form-control" name="activitePro1" placeholder="Activité" value="<?php echo $_SESSION['postedForm']['activitePro1'] != '' ? $_SESSION['postedForm']['activitePro1'] : ''; ?>"/> <input type="text" class="form-control" name="activitePro1" placeholder="Activité" value="<?php echo $_SESSION['postedForm']['activitePro1'] != '' ? $_SESSION['postedForm']['activitePro1'] : ''; ?>"/>
</td> </td>
<td> <td>
<label for="anneesPro1">Années</label>
<input type="text" class="form-control" name="anneesPro1" placeholder="de-à (années)" value="<?php echo $_SESSION['postedForm']['anneesPro1'] != '' ? $_SESSION['postedForm']['anneesPro1'] : ''; ?>"/> <input type="text" class="form-control" name="anneesPro1" placeholder="de-à (années)" value="<?php echo $_SESSION['postedForm']['anneesPro1'] != '' ? $_SESSION['postedForm']['anneesPro1'] : ''; ?>"/>
</td> </td>
</tr> </tr>
......
<table id="scolaire"> <table id="scolaire">
<tr>
<th>Ecole</th>
<th>Lieu</th>
<th>Niveau</th>
<th>Années</th>
</tr>
<tr> <tr>
<td> <td>
<label for="ecole1">Ecole</label>
<input type="text" name="ecole1" placeholder="Ecole *" class="form-control" value="<?php echo $_SESSION['postedForm']['ecole1'] != '' ? $_SESSION['postedForm']['ecole1'] : ''; ?>" data-required/> <input type="text" name="ecole1" placeholder="Ecole *" class="form-control" value="<?php echo $_SESSION['postedForm']['ecole1'] != '' ? $_SESSION['postedForm']['ecole1'] : ''; ?>" data-required/>
</td> </td>
<td> <td>
<label for="lieuEcole1">Lieu</label>
<input type="text" name="lieuEcole1" placeholder="Lieu *" class="form-control" value="<?php echo $_SESSION['postedForm']['lieuEcole1'] != '' ? $_SESSION['postedForm']['lieuEcole1'] : ''; ?>" data-required/> <input type="text" name="lieuEcole1" placeholder="Lieu *" class="form-control" value="<?php echo $_SESSION['postedForm']['lieuEcole1'] != '' ? $_SESSION['postedForm']['lieuEcole1'] : ''; ?>" data-required/>
</td> </td>
<td> <td>
<label for="niveauEcole1">Niveau</label>
<input type="text" name="niveauEcole1" placeholder="Niveau *" class="form-control" value="<?php echo $_SESSION['postedForm']['niveauEcole1'] != '' ? $_SESSION['postedForm']['niveauEcole1'] : ''; ?>" data-required/> <input type="text" name="niveauEcole1" placeholder="Niveau *" class="form-control" value="<?php echo $_SESSION['postedForm']['niveauEcole1'] != '' ? $_SESSION['postedForm']['niveauEcole1'] : ''; ?>" data-required/>
</td> </td>
<td> <td>
<label for="anneesEcole1">Années</label>
<input type="text" name="anneesEcole1" placeholder="de-à (années) *" class="form-control" value="<?php echo $_SESSION['postedForm']['anneesEcole1'] != '' ? $_SESSION['postedForm']['anneesEcole1'] : ''; ?>" data-required/> <input type="text" name="anneesEcole1" placeholder="de-à (années) *" class="form-control" value="<?php echo $_SESSION['postedForm']['anneesEcole1'] != '' ? $_SESSION['postedForm']['anneesEcole1'] : ''; ?>" data-required/>
</td> </td>
</tr> </tr>
......
<table id="stages"> <table id="stages">
<tr>
<th>Métier</th>
<th>Entreprise</th>
</tr>
<tr> <tr>
<td> <td>
<label for="activiteStage1">Métier</label>
<input type="text" name="activiteStage1" class="form-control" placeholder="Métier" value="<?php echo $_SESSION['postedForm']['activiteStage1'] != '' ? $_SESSION['postedForm']['activiteStage1'] : ''; ?>"> <input type="text" name="activiteStage1" class="form-control" placeholder="Métier" value="<?php echo $_SESSION['postedForm']['activiteStage1'] != '' ? $_SESSION['postedForm']['activiteStage1'] : ''; ?>">
</td> </td>
<td> <td>
<label for="entrepriseStage1">Entreprise</label>
<input type="text" name="entrepriseStage1" class="form-control" placeholder="Entreprise" value="<?php echo $_SESSION['postedForm']['entrepriseStage1'] != '' ? $_SESSION['postedForm']['entrepriseStage1'] : ''; ?>"> <input type="text" name="entrepriseStage1" class="form-control" placeholder="Entreprise" value="<?php echo $_SESSION['postedForm']['entrepriseStage1'] != '' ? $_SESSION['postedForm']['entrepriseStage1'] : ''; ?>">
</td> </td>
</tr> </tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment