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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="fr" />
<title>Petites annonces gratuites</title>
<meta name="Description" content="Déposez votre annonces gratuitement." />
<script type="text/javascript" src="boite.js"></script>
<script type="text/javascript">
function removeOptions(divId){
var monTableau = ["dpt1", "dpt2", "dpt3"];
for (var i=0;i<monTableau.length;i++){
if(monTableau[i] != "dpt"+divId){
var optionsDiv = document.getElementById(monTableau[i]).getElementsByTagName("select");
for (var j=0;j<optionsDiv.length;j++){
optionsDiv[0].selectedIndex = '';
}
}
}
}
function selectDpt(regions,dpt){
var optionsDiv = document.getElementById('dpt'+regions).getElementsByTagName("select");
for (var j=0;j<optionsDiv[0].length;j++){
if(optionsDiv[0][j].value == dpt){
optionsDiv[0].selectedIndex = j;
}
}
}
</script>
<style>
label{
display:inline;
font-weight:bold;
}
select,input{
margin:5px;
}
.espace{
margin:0 10px 0 0;
color:blue;
font-weight:bold;
}
.couleur{
color:green;
}
.erreur{
color:red;
border: 1px solid red;
width:500px;
height:auto;
margin:5px;
padding:5px;
background-color:#FAB9AD;
}
</style>
</head>
<body>
<form name="listes" action="#ancre_formulaire" method="post">
<label>Région :</label>
<select name="region" onchange="afficheBoitedpt(this.value);removeOptions(this.value);">
<option value="0">«Choisissez la région»</option>
<option value="1">Alsace</option>
<option value="2">Aquitaine</option>
<option value="3">Auvergne</option>
</select>
<br/>
Après validation, la boite département disparait, ce qui empêche une re sélection ainsi qu'une visualisation du département sélectionné.
<div id='dpt1' style='display:none;'><label>Département :</label>
<select name="departement1">
<option value="0">«Choisissez»</option>
<option value="1">Bas-Rhin</option>
<option value="2">Haut-Rhin</option>
</select>
</div>
<div id='dpt2' style='display:none;'><label>Département :</label>
<select name="departement2">
<option value="0">«Choisissez»</option>
<option value="3">Dordogne</option>
<option value="4">Gironde</option>
<option value="5">Landes</option>
<option value="6">Lot-et-Garonne</option>
<option value="7">Pyrénées-Atlantiques</option>
</select>
</div>
<div id='dpt3' style='display:none;'><label>Département :</label>
<select name="departement3">
<option value="0">«Choisissez»</option>
<option value="8">Allier</option>
<option value="9">Cantal</option>
<option value="10">Haute-Loire</option>
<option value="11">Puy-de-dôme</option>
</select>
</div>
<input class="boutton" name="envoyer" value="envoyer" type="submit"/>
<input class="boutton" name="Effacer" value="Effacer" type="reset"/>
</form>
<?php
if($_POST['region']){
echo "région : ".$_POST['region'].'<br />';
echo "<script type=\"text/javascript\">document.listes.region.selectedIndex = ".$_POST['region'].";</script>";
echo "<script type=\"text/javascript\">afficheBoitedpt(".$_POST['region'].");</script>";
}
if($_POST['departement1']){
echo "dep1 : ".$_POST['departement1'].'<br />';
echo "<script type=\"text/javascript\">selectDpt(1,".$_POST['departement1'].");</script>";
}
if($_POST['departement2']){
echo "dep2 : ".$_POST['departement2'].'<br />';
echo "<script type=\"text/javascript\">selectDpt(2,".$_POST['departement2'].");</script>";
}
if($_POST['departement3']){
echo "dep3 : ".$_POST['departement3'].'<br />';
echo "<script type=\"text/javascript\">selectDpt(3,".$_POST['departement3'].");</script>";}
?>
</body>
</html> |
Partager