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
|
<head>
//...
<script type='text/javascript'>
var xhr = null;
function getXhr(){
if(window.XMLHttpRequest) // Firefox and others
xhr = new XMLHttpRequest();
else if(window.ActiveXObject){ // Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest not supported by the navigator
alert("Your navigator doesn't support XMLHTTPRequest objects... please activate javascript or contact hotline");
xhr = false;
}
}
/**
* This method will change the project name in the textbox according to the selected project.
*/
function UpdateName(){
getXhr();
// Definition of what to do when we'll have the server response
xhr.onreadystatechange = function(){
// If everything has been received and if the server is ok
if(xhr.readyState == 4 && xhr.status == 200){
NewHTMLCode = xhr.responseText;
// We use innerHTML to change the HTML code
document.getElementById('Name').innerHTML = NewHTMLCode ;
//Call of the function that updates the next field
UpdateCustomer();
}
}
// Here we post the informations to generate the new HTML code
xhr.open("POST","ModifyProject-FieldUpdate.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
sel = document.getElementById('Project');
projectid = sel.options[sel.selectedIndex].value;
xhr.send('ProjectID='+projectid+'&FieldNumber=1');
}
// plein d'autres fonction ou juste le nom le fieldnumber et la fonction appelée changent...
/**
* This method will set the current phase as default in the Phase dropdown menu according to the selected project.
*/
function UpdatePhase(){
getXhr();
// Definition of what to do when we'll have the server response
xhr.onreadystatechange = function(){
// If everything has been received and if the server is ok
if(xhr.readyState == 4 && xhr.status == 200){
NewHTMLCode = xhr.responseText;
// We use innerHTML to change the HTML code
document.getElementById('Phase').innerHTML = NewHTMLCode ;
//Call of the function that updates the next field
UpdatePhaseDate();
}
}
// Here we post the informations to generate the new HTML code
xhr.open("POST","ModifyProject-FieldUpdate.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
sel = document.getElementById('Project');
projectid = sel.options[sel.selectedIndex].value;
xhr.send('ProjectID='+projectid+'&FieldNumber=11');
}
function UpdatePhaseDate(){
getXhr();
// Definition of what to do when we'll have the server response
xhr.onreadystatechange = function(){
// If everything has been received and if the server is ok
if(xhr.readyState == 4 && xhr.status == 200){
NewHTMLCode = xhr.responseText;
// We use innerHTML to change the HTML code
document.getElementById('PhaseDate').innerHTML = NewHTMLCode ;
// Call of the function that updates the next field
UpdateDecision();
}
}
// Here we post the informations to generate the new HTML code
xhr.open("POST","ModifyProject-FieldUpdate.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
sel1 = document.getElementById('Project');
projectid = sel1.options[sel1.selectedIndex].value;
alert("sel1 "+sel1.options[sel1.selectedIndex].value);
sel2 = document.getElementById('PhaseNumber');
alert("sel2 "+sel2.options[sel2.selectedIndex].value);
alert("alors?");
phasenumber = sel2.options[sel2.selectedIndex].value;
alert(phasenumber);
xhr.send('ProjectID='+projectid+'&FieldNumber=12&PhaseNumber='+phasenumber);
//xhr.send('ProjectID='+projectid+'&FieldNumber=12');
}
//...
</script>
</head>
<body>
<?php
// declaration of a few variables
$host = "localhost";
$user = "root";
$pass = "xxxx";
$bdd = "database";
// connection with MySQL
@mysql_connect($host, $user, $pass) or die("Database unreachable...");
// the @ is used to tell php not to display the error message
@mysql_select_db($bdd) or die("Database unreachable...");
// We create an array in order to number the months (0 => January, 1 => February...)
$months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
?>
form method=post action="ModifyProject-SendToDB.php">
<div style="width:100%;">
<div style="position:relative; margin-top:100px;">
<p align="center" style="position:relative; top:10px;">
Select a project
<select size="1" name='Project' id='Project' style="vertical-align: middle; position: relative" onchange='UpdateName()'>
<?php
// completion of the dropdown with the data from the database.
$SQL = "SELECT Name,ProjectID FROM PROJECT" ;
$result = mysql_query($SQL) or die('Erreur SQL : '.mysql_error());
while ($val = mysql_fetch_array($result)){
$Name=htmlentities($val["Name"]);
echo "<OPTION VALUE='".$val["ProjectID"]."'>".$Name."</option>";
}
?>
</select>
</p>
</div>
// ....
<fieldset class="ligne" style="height:520px">
<legend>ETM Phases</legend>
<span [b]id='Phase' <-- le pb était là !!![/b]style="position:absolute; left:3%;">
Phase
<select size="1" id="PhaseNumber" name="PhaseNumber" style="vertical-align: middle; position: relative"
onchange="alert(this.options[this.selectedIndex].value)">
<option value='-2'>No Phase</option>
<option value='-1'>Kick Off</option>
<option value='0'>Phase 0</option>
<option value='1'>Phase 1</option>
<option value='2'>Phase 2</option>
<option value='3'>Phase 3</option>
<option value='4'>Phase 4</option>
</select>
</span>
<span id='PhaseDate' style="position:absolute; left:26%;">
Date
<select size="1" name="DateMonth" style="vertical-align: middle; position: relative">
<?php
// completion of the dropdown with each month of the year
for ($month = 1; $month<= 12; $month++)
{
echo "<option value='".$month."'>".$months[$month-1]."</option>";
}
?>
</select>
<select size="1" name="DateDay" style="vertical-align: middle; position: relative">
<?php
// completion of the dropdown with each day of the month
for ($day = 1; $day <= 31; $day++)
{
echo "<option value='".$day."'>".$day."</option>";
}
?>
</select>
<select size="1" name="DateYear">";
<?php
// completion of the dropdown with the each year from 2004 to now + 1 year
for ($year = 2004; $year<=date('Y')+1; $year++)
{
echo "<option value='".$year."'>".$year."</option>";
}
?>
</select>
</span>
//...
</fieldset>
</form>
<?php
// déconnection avec MySQL
mysql_close();
?>
</body>
</html> |
Partager