
mechergui
|
voila c le contenu de ma page de test :
<?php include("foncts.php");
?> <!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" /> <title>Document sans titre</title> </head> <body onLoad="<?php switch($phase) { case 0: default: break; case 1: echo "SetAge(); ChangeCountry(getRefio('pays'));"; break; case 2: echo "window.setInterval('TimerNbrChars()', 1000);"; break; case 3: echo "window.setInterval('TimerNbrChars()', 1000);"; break; } ?>"> <table border="0"> <tr> </tr> <?php // writeError('pays', $result_basic); ?> <tr> <td class="fielddesc"> <font color="#FF0000"><b>*</b></font>Mon pays : </td> <td> <select rel="help_pays" name="pays" id="pays" onChange="ChangeCountry(this)" style="width: 200px"> <?php //MBJ if(isset($_POST['pays'])) $country = $_POST['pays']; else { $country = "France"; include('pays.php'); include('communes.php'); sort($pays); foreach($pays as $val) { echo '<option value="'.$val.'"'; if($val == $country) echo ' selected="selected"'; echo '>'.$val.'</option>'; } } ?> </select> </td> </tr> <?php // writeError('commune', $result_basic); $csd = file_get_contents('communes'); $communes = unserialize($csd); $commune = (isset($_POST['commune']) ? $_POST['commune'] : ""); $region = (isset($_POST['region']) ? $_POST['region'] : ""); $departement = (isset($_POST['departement']) ? $_POST['departement'] : ""); ?> <tr id="row_region"> <td class="fielddesc"> <font color="#FF0000"><b>*</b></font>Ma région : </td> <td> <select rel="help_pays" name="region" id="region" style="width: 200px" onChange="ChangeRegion(this)"> <?php if($region == "") { ?> <option value="none">Choisir la region</option> <?php } ?> <?php foreach($communes as $ind => $val) { echo '<option value="'.$ind.'"'; if($ind == $region) echo ' selected="selected"'; echo '>'.$ind.'</option>'; } ?> </select> </td> </tr> <tr id="row_departement"> <td class="fielddesc"> <font color="#FF0000"><b>*</b></font>Mon département : </td> <td> <select rel="help_pays" name="departement" id="departement" onChange="ChangeDepartement(this)" style="width: 200px"> <?php if($departement == "") { ?><option value="none" selected="selected">Choisir le département</option><?php } ?> <?php if($region != "" && isset($communes[$region])) { foreach($communes[$region] as $ind => $val) { echo '<option value="'.$ind.'"'; if($ind == $departement) echo ' selected="selected"'; echo '>'.$ind.'</option>'; } } ?> </select> </td> </tr> <tr id="row_commune"> <td class="fielddesc"> <font color="#FF0000"><b>*</b></font>Ma commune : </td> <td> <select rel="help_pays" name="commune" id="commune" style="width: 200px"> <?php if($commune == "") { ?><option value="none">Choisir la commune</option><?php } ?> <?php if($region != "" && isset($communes[$region]) && $departement && isset($communes[$region][$departement])) { foreach($communes[$region][$departement] as $val) { echo '<option value="'.$val.'"'; if($val == $commune) echo ' selected="selected"'; echo '>'.$val.'</option>'; } } ?> </select> </td> </tr> <tr id="row_ville" style="visibility: hidden; display: none"> <td class="fielddesc"> Ma ville : </td> <td> <input type="text" name="ville" value="<?php if(isset($_POST['commune'])) echo $_POST['commune']; ?>" id="ville" rel="help_pays" /> </td> </tr> </table> </body> </html>
et voici la page contenant le sfonctions js :
<!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" /> <title>Document sans titre</title> <script>
var isDOM3 = (document.getElementById ? true : false); var isIE43 = ((document.all && !isDOM3) ? true : false); var isNS43 = (document.layers ? true : false);
function getRefio(id) { if (isDOM3) return document.getElementById(id); if (isIE43) return document.all[id]; if (isNS43) return document.layers[id]; }
function GetLocations(selectObj, targetid, region, departement) { var idx = selectObj.selectedIndex; var which = selectObj.options[idx].value;
var requestObj; if(window.XMLHttpRequest) requestObj = new XMLHttpRequest(); else if(window.ActiveXObject) requestObj = new ActiveXObject("Microsoft.XMLHTTP"); else return false; requestObj.open("GET", "getcommunes.php?region=" + escape(region) + "&departement=" + escape(departement), false); requestObj.send(null); var cList; if(requestObj.readyState == 4) { cList = requestObj.responseText.split("#"); } if(!cList) return false; var cSelect = getRefio(targetid); var len = cSelect.options.length; while (cSelect.options.length > 0) { cSelect.remove(0); } var newOption; for (var i=0; i<cList.length; i++) { newOption = document.createElement("option"); newOption.value = cList[i]; newOption.text = cList[i]; try { cSelect.add(newOption); } catch (e) { cSelect.appendChild(newOption); } } return true; }
function ChangeCountry(obj) { var id = obj.selectedIndex; var country = obj.options[id].value;
var rowsFrance = ['row_region', 'row_departement', 'row_commune']; var rowsNonFrance = ['row_ville']; for(var i = 0; i < rowsFrance.length; i++) { if(country == "France") { getRefio(rowsFrance[i]).style.visibility = "visible"; getRefio(rowsFrance[i]).style.display = ""; } else { getRefio(rowsFrance[i]).style.visibility = "hidden"; getRefio(rowsFrance[i]).style.display = "none"; } } for(var i = 0; i < rowsNonFrance.length; i++) { if(country != "France") { getRefio(rowsNonFrance[i]).style.visibility = "visible"; getRefio(rowsNonFrance[i]).style.display = ""; } else { getRefio(rowsNonFrance[i]).style.visibility = "hidden"; getRefio(rowsNonFrance[i]).style.display = "none"; } } }
function ChangeRegion(obj) { var idreg = obj.selectedIndex; var region = obj.options[idreg].value; GetLocations(obj, 'departement', region, "", ""); ChangeDepartement(getRefio('departement')); }
function ChangeDepartement(obj) { var iddep = obj.selectedIndex; var departement = obj.options[iddep].value; var objregion = getRefio('region'); var idreg = objregion.selectedIndex; var region = objregion.options[idreg].value; GetLocations(obj, 'commune', region, departement, ""); }
function nbrChars(objid, countid) { getRefio(countid).innerHTML = getRefio(objid).value.length; }
</script> </head>
<body> </body> </html>
pays.php :
<?php $pays = array("France","Suisse","Belgique","Allemagne","Danemark","Espagne","Italie", "Portugal","Bulgarie","Hongrie","Finlande","Suède","Roumanie","Rép.Tchèque","Pologne", "Pays-Bas","Norvège","Luxembourg","Royaume-Uni","Irlande","Grèce","Canada","Etats-Unis", "Mexique","Cuba","Rép.Dominicaine","Haïti","Jamaïque","Argentine","Barbade","Bolivie", "Belize","Brésil","Chili","Colombie","Costa Rica","Equateur","El Salvador","Grenade", "Guadeloupe","Guatémala","Guyana","Guyane","Honduras","Martinique","Nicaragua","Panama", "Paraguay","Pérou","Surinam","Uruguay","Vénézuéla","Australie","Nouvelle-Calédonie", "Nouvelle-Zélande","Algérie","Afrique du Sud","Angola","Bénin","Botswana", "Burkina Faso","Burundi","Cameroun","Cap-Vert","Centrafrique","Congo","Congo (RDC)", "Côte-d'Ivoire","Djibouti","Erythrée","Ethiopie","Gabon","Gambie","Ghana","Guinée", "Guinée Bissau","Guinée Equatoriale","Kenya","Ile Maurice","Lesotho","Libéria", "Madagascar","Malawi","Mali","Maroc","Mauritanie","Mozambique","Namibie","Niger", "Nigeria","Ouganda","Rwanda","Sao Tomé","Sénégal","Sierra Leone","Somalie","Soudan", "Swaziland","Tanzanie","Tchad","Togo","Tunisie","Zambie","Zimbabwe","Arabie-Saoudite", "Arménie","Bangladesh","Cambodge","Chine","Corée du nord","Corée du sud","Inde", "Israël","Jordanie","Liban","Malaisie","Maldives","Mongolie","Népal","Pakistan", "Paléstine","Philippines","Sri Lanka","Japon","Thaïlande","Russie","Québec"); ?>
mais le fichier commune contient plaus qu un mega j peu pa le coller la et je sé pas comment le joindre
|