msi79
Messages postés499Date d'inscriptionlundi 24 août 2009StatutMembreDernière intervention 2 mai 2023
-
5 sept. 2018 à 11:27
msi79
Messages postés499Date d'inscriptionlundi 24 août 2009StatutMembreDernière intervention 2 mai 2023
-
9 sept. 2018 à 20:31
Bonjour,
j'ai une liste déroulante et j’aimerai récupérer ces valeurs après avoir fait un submit.
NB: hier jordane45 m'a aidé à afficher les valeur de cette mème liste déroulante .
voici le formulaire traité hier.
<?php
/**
* Petit rappel
* comment écrire correctement son code en php :
* http://www.commentcamarche.net/faq/48399-php-gestion-des-erreurs-debogage-et-ecriture-du-code
*/
//-------------------------------------------//
//affichage des erreurs php
//-------------------------------------------//
/*
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
*/
//-------------------------------------------//
//connexion à la bdd
//-------------------------------------------//
//require_once 'connect_pdo.php';
//-------------------------------------------//
//VERIF L'EXISTENCE DU TELEPHONE
//-------------------------------------------//
$sql = "SELECT *
FROM tb_sous_famille SF
LEFT JOIN cree_produit P ON P.id_sousfamille = SF.id
ORDER BY SF.design ";
try{
$req_1 = $pdo->prepare($sql);
$req_1->execute();
$resulsMDP = $req_1->fetchAll();
}catch(PDOException $e){
echo "ERREUR DE REQUETE : " . $sql . ' error : '.$e->getMessage();
}
$nbr = !empty($resulsMDP) ? count($resulsMDP) : 0;
/* $arrDesigns = array();
if(!empty($resulsMDP)){
foreach($resulsMDP as $R){
$arrDesigns[] = $R['design']; //echo $arrDesigns[1];
}
}
*/
$arrDesigns = array();
if(!empty($resulsMDP)){
foreach($resulsMDP as $R){
$arrDesigns[$R['design']] = $R['design'];
}
}
$arrPacks = array();
if(!empty($resulsMDP)){
foreach($resulsMDP as $R){
$arrPacks[$R['design']][] = $R['produit'];
}
}
?>
<script type="text/javascript" src="./js/dept_xhr_detail.js" charset="iso_8859-1"></script>
<form action="" method="post" id="chgdept" >
<div class="row">
<div class="col-md-6 mb-3">
<label for="validationCustom03">Category:</label>
<select class="form-control form-control-lg" name="category" id="validationCustom03" onchange="ChangecatList()" required>
<option value="">Choose... </option>
<?php
if(!empty($arrDesigns)){
foreach($arrDesigns as $D){
echo '<option value="'.$D.'">'.$D.'</option>';
}
}
?>
<option value="Curriculum Development and Alignment">Curriculum Development and Alignment</option>
<option value="District Committee">District Committee</option>
</select>
<div class="invalid-feedback">
</div>
</div>
<div class="col-md-6 mb-3">
<label for="validationCustom04">Activity:</label>
<select class="form-control form-control-lg" id="validationCustom04" name="produit" onchange="getDepartements_detail(this.value);"></select>
<div class="invalid-feedback">
</div>
</div>
</div>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-4">
<input type="submit" class="btn btn-primary btn-lg btn-block" name="ok" id="ok" value="Enregistrer" />
</div>
<div class="col-md-3"></div>
</div>
</form>
le code js:
<script type="text/javascript">
var catAndActs = <?php echo json_encode($arrPacks) ?>;
catAndActs['Curriculum Development and Alignment'] = ['Capstone Development', 'Course Of Study Development / Revision', 'Standards Alignment / Rollout', 'Other'];
//pour voir dans la console ce que ça donne :
console.log("catAndActs :");
console.log(catAndActs);
function ChangecatList() {
var catList = document.getElementById("validationCustom03");
var actList = document.getElementById("validationCustom04");
var selCat = catList.options[catList.selectedIndex].value;
actList.innerHTML = "";
var cats = catAndActs[selCat];
console.log('selCat : ' + selCat);
console.log('cats : ' + cats);
if (cats) {
for (var i = 0; i < cats.length; i++) {
var cat = new Option(cats[i], i);
actList.options.add(cat);
}
}
}
</script>
quand je clique sur le bouton valider , par exemple pour le produit NEON, c'est plutot 1 qui est envoyé au lieu de NEON . Ce 1 ne correspon ni a l'ID de NEON ni à l'ID de la catégorie.
NB j'aime avoir un ruc qu genre
3/NEON avec 3 comme ID de NEON . je ferai un explode() pour recuperer le ID de NEON et NEON lui meme.
8 sept. 2018 à 20:48
même en regardant la :
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement/Option
8 sept. 2018 à 21:14
Par exemple
8 sept. 2018 à 22:51
GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/css/bootstrap.min.css 404 (Not Found)
index.php:284 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/css/dataTables.bootstrap.min.css 404 (Not Found)
index.php:285 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/css/buttons.bootstrap.min.css 404 (Not Found)
index.php:287 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/jquery-1.12.4.js 404 (Not Found)
index.php:288 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/jquery.dataTables.min.js 404 (Not Found)
index.php:289 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/dataTables.bootstrap.min.js 404 (Not Found)
index.php:293 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/pdfmake.min.js 404 (Not Found)
index.php:290 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/dataTables.buttons.min.js 404 (Not Found)
index.php:291 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.bootstrap.min.js 404 (Not Found)
index.php:292 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/jszip.min.js 404 (Not Found)
index.php:294 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/vfs_fonts.js 404 (Not Found)
index.php:295 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.html5.min.js 404 (Not Found)
index.php:296 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.print.min.js 404 (Not Found)
index.php:297 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.colVis.min.js 404 (Not Found)
index.php?page=STOCK:283 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/css/bootstrap.min.css 404 (Not Found)
index.php?page=STOCK:284 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/css/dataTables.bootstrap.min.css 404 (Not Found)
index.php?page=STOCK:285 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/css/buttons.bootstrap.min.css 404 (Not Found)
index.php?page=STOCK:287 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/jquery-1.12.4.js 404 (Not Found)
index.php?page=STOCK:288 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/jquery.dataTables.min.js 404 (Not Found)
index.php?page=STOCK:289 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/dataTables.bootstrap.min.js 404 (Not Found)
index.php?page=STOCK:290 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/dataTables.buttons.min.js 404 (Not Found)
index.php?page=STOCK:291 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.bootstrap.min.js 404 (Not Found)
index.php?page=STOCK:292 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/jszip.min.js 404 (Not Found)
index.php?page=STOCK:293 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/pdfmake.min.js 404 (Not Found)
index.php?page=STOCK:294 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/vfs_fonts.js 404 (Not Found)
index.php?page=STOCK:295 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.html5.min.js 404 (Not Found)
index.php?page=STOCK:296 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.print.min.js 404 (Not Found)
index.php?page=STOCK:297 GET http://localhost/chicsape_codebar_new.com/bootstrap_lien/js/buttons.colVis.min.js 404 (Not Found)
8 sept. 2018 à 23:21
Sinon ça me sert à rien.
9 sept. 2018 à 09:24
ça doit etre ça je crois .
catAndActs :
index.php?page=STOCK:414 {AMPOULES: Array(3), CLEF USB: Array(2), MARQUEUR: Array(1), VINS: Array(1), VOLAILLE: Array(5), …}
index.php?page=STOCK:423 selCat : AMPOULES
index.php?page=STOCK:426 cats : (3) ["AMPOULE ECONOMIQUE", "NEON", "AMPOULE 250WATT"]
index.php?page=STOCK:430 Ajout option : AMPOULE ECONOMIQUE i = 0
index.php?page=STOCK:430 Ajout option : NEON i = 1
index.php?page=STOCK:430 Ajout option : AMPOULE 250WATT i = 2
index.php?page=STOCK:423 selCat : VINS
index.php?page=STOCK:426 cats : ["Muscador shake"]
index.php?page=STOCK:430 Ajout option : Muscador shake i = 0
index.php?page=STOCK:423 selCat : AMPOULES
index.php?page=STOCK:426 cats : (3) ["AMPOULE ECONOMIQUE", "NEON", "AMPOULE 250WATT"]
index.php?page=STOCK:430 Ajout option : AMPOULE ECONOMIQUE i = 0
index.php?page=STOCK:430 Ajout option : NEON i = 1
index.php?page=STOCK:430 Ajout option : AMPOULE 250WATT i = 2
index.php?page=STOCK:423 selCat : VINS
index.php?page=STOCK:426 cats : ["Muscador shake"]
index.php?page=STOCK:430 Ajout option : Muscador shake i = 0