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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.Vector,java.util.Enumeration,GC.bean.Bien,
GC.bean.Projet,GC.bean.Tranche,GC.bean.Groupement,GC.dao.GroupementDAO,
GC.dao.ProjetDAO,java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<script type='text/javascript'>
function getXhr(){
var xhr = null;
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest();
else if(window.ActiveXObject){ // Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
return xhr;
}
/**
* Méthode qui sera appelée sur le click du bouton
*/
function change()
{
//Si c'est AUCUN qui est sélectionné, il faut réinitialiser
//les 2 autres combos et quitter
var sel = document.getElementById('projet');
if (sel.options[sel.selectedIndex].value == -1) {
document.getElementById('tranche').options.length=0;
document.getElementById('groupement').options.length=0;
return;
}
var xhr = getXhr();
// On défini ce qu'on va faire quand on aura la réponse
xhr.onreadystatechange = function()
{
//attendons dque le requete soit finie...
if(xhr.readyState == 4 && xhr.status == 200){
var rst = xhr.responseXML;
var items=rst.getElementsByTagName('element');
document.getElementById('tranche').options.length=0;
//penser à réinitialiser aussi id_ref
document.getElementById('groupement').options.length=0;
for(var i=0;i<items.length;i++)
{
var myOption = new option(items[i].getElementsByTagName('option')[0].firstChild.nodeValue,items[i].getElementsByTagName('valeur')[0].firstChild.nodeValue,false,true)
document.getElementById('tranche').options[i]=myOption;
}
//mise à jour de id_ref pour le 1er prenom affiché (sinon incohérence
//au niveau de l'affichage)
change2();
}
}
// Ici on va voir comment faire du post
xhr.open("POST","cmbtranche22.jsp",true);
// ne pas oublier ça pour le post
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
// ne pas oublier de poster les arguments
// ici, l'id de l'auteur
sel = document.getElementById('projet');
idprojet = sel.options[sel.selectedIndex].value;
xhr.send("idProjet="+idprojet);
}
function change2()
{
//si un seul prenom...
if (document.getElementById('prenom').options.length==1)
{
//on vide la derniere combo
document.getElementById('groupement').options.length=0;
//on quitte
return;
}
var xhr = getXhr();
// On défini ce qu'on va faire quand on aura la réponse
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4 && xhr.status == 200){
var rst = xhr.responseXML;
var items=rst.getElementsByTagName('element');
document.getElementById('groupement').options.length=0;
for(var i=0;i<items.length;i++)
{
var myOption = new Option(items[i].getElementsByTagName('option')[0].firstChild.nodeValue,items[i].getElementsByTagName('valeur')[0].firstChild.nodeValue,false,true)
document.getElementById('groupement').options[i]=myOption;
}
}
}
// Ici on va voir comment faire du post
xhr.open("POST","cmbgroupement22.jsp",true);
// ne pas oublier ça pour le post
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
// ne pas oublier de poster les arguments
// ici, l'id de l'auteur
sel2 = document.getElementById('projet');
idprojet = sel2.options[sel2.selectedIndex].value;
sel = document.getElementById('tranche');
idtranche = sel.options[sel.selectedIndex].value;
xhr.send("idTranche="+idtranche + "idProjet="+idprojet);
}
</script>
<body onload = 'change()'>
<form method="POST" action="NouveauBien">
<fieldset style="padding: 2">
<legend>Information sur le Bien</legend>
<b>Identificateur : <input type="text" name="id_bien" size="20"></b><p>
<b>GH :
<input type="text" name="gh" size="20"></b></p>
</fieldset><p> </p>
<fieldset style="width: 500px">
<legend>Information sur Projet</legend>
<label>Projet</label>
<select name="projet" onchange='change()'>
<%
Projet prj = (Projet) application.getAttribute("prj");
Collection prjs = ProjetDAO.getProjetId();
if (prjs != null)
{
if (prjs.size() > 0)
{
for (Iterator iterator = prjs.iterator(); iterator.hasNext(); )
{
Projet prjts = (Projet) iterator.next ();
%>
<OPTION value ="<%=prjts.getCode_projet()%>">
<%out.print(prjts.getLibelle());%>
</OPTION>
<%
}
}
}
%>
</select>
<label>Tranche</label>
<div id='tranche' style='display:inline'>
<select name="tranche" onchange='change2()'>
<option value='-1'>Choisir un projet</option>
</select>
</div>
<label>Groupement</label>
<div id='groupement' style='display:inline'>
<select name="groupement">
<option value='-1'>Choisir un projet ou tranche</option>
</select>
</div>
</fieldset>
<p><b>Superficie : </b>
<input type="text" name="superficie" size="20"></p>
<p> </p>
<p><input type="submit" value="Enregistrer" name="B1"></p>
<p> </p>
<p> </p>
</form>
</body>
</html> |