Récupérer text d'un select
bonjour à tous ,
voilà je tente de récupérer la valeur text d'un champ ' select ' sélectionnner , mais sans succès, sachant que je suis débutant ....
voilà ce que j'ai fait : ( merci pour votre aide )
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <?php
include('connect.php');
$Id_bien = 1;
$resultat=$pdo->query("SELECT * FROM criteres_bien WHERE Id_bien = '".$Id_bien."'");
$resultat->setFetchMode(PDO::FETCH_OBJ);
$result_criteres_bien = $resultat->fetch();
?>
<select class="users" id="select" name="nombre_chambres" onchange="change_valeur();">
<option selected="selected"><?php echo ($result_criteres_bien->nombre_chambre);?></option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select><br>
<script>
function change_valeur() {
select = document.getElementById("select");
choice = select.selectedIndex;
texte = select.options[choice].text;
$choix = texte;
}
</script>
<?php
for ($i = 1; $i <= $choix; $i++) {
echo '<label>Chambre '.$i.': <input type="text" name="chambre_'.$i.'" value="'.$result_criteres_bien->surface_bien.'"></label> m²<br><br>';
}
?> |