à ta connaissance, peut être que non, mais à la mienne, oui
put1, que de lignes pour faire un simple tableau
a++
]]><select name="status">
.
Est il possible d'ecrire
<select name="status" id="status">
et ensuite de faire:
Si j'ai totelement tort, y a t-il une autre facon d'aborder ce probleme? parceque JS est entrain de me rendre dingue.
Merci
]]>/*var cell3=xhr.responseText;
document.getElementById('status').innerHTML = cell3;
cell_3.appendChild(cell3);*/
//row.appendChild(cell_3);
Les autres cellules s'affichent quand je clique sur Ajouter
Comment pusi je faire pour parfaitement interpreter ma liste deroulante renvoyee par AJAX?
Merci
]]>J' ai modifie mon code de facon a creer mes cellules tdans javascript.
alors j'ai une fichier fstatus.php execute avec AJAX:
?>
Il est tout simple et me renvoie juste ma liste deroulante.
Ensuite j'ai le fichier funcs.php comme ceci:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function getXhr(){
var xhr = null;
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 your browser
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
return xhr
}
/**
* method called when the user clicks on the button
*/
function go(){
var xhr = getXhr()
// We defined what we gonna do with the response
xhr.onreadystatechange = function(){
// We do somthing once the server's response is OK
if(xhr.readyState == 4 && xhr.status == 200){
var body = document.getElementsByTagName("body")[0];
// Retrieve <table> element and create a <tbody> element
var tbl = document.getElementById("table");
var tblBody = document.createElement("tbody");
var row = document.createElement("tr");
// Create <td> elements and a text node, make the text
// node the contents of the <td>, and put the <td> at
// the end of the table row
var cell_1 = document.createElement("td");
var cell_2 = document.createElement("td");
var cell_3 = document.createElement("td");
var cell_4 = document.createElement("td");
// Create the first cell which is a text zone
var cell1=document.createElement("input");
cell1.type="text";
cell1.name="fname";
cell1.size="20";
cell1.maxlength="50";
cell_1.appendChild(cell1);
// Create the second cell which is a text area
var cell2=document.createElement("textarea");
cell2.name="fdescription";
cell2.rows="2";
cell2.cols="30";
cell_2.appendChild(cell2);
// Create the third cell which is a combo box
// retrieve the xhr response and put it on a cell
var cell3=xhr.responseText;
document.getElementById('status').innerHTML = cell3;
cell_3.appendChild(cell3);
// Create the fourth cell which is a href
var cell4 = document.createElement("a");
cell4.setAttribute("href","delete.php");
cell4.appendChild(document.createTextNode("[Delete]"));
cell_4.appendChild(cell4);
// add cells to the row
row.appendChild(cell_1);
row.appendChild(cell_2);
row.appendChild(cell_3);
row.appendChild(cell_4);
// add the row to the end of the table body
tblBody.appendChild(row);
// put the <tbody> in the <table>
tbl.appendChild(tblBody);
// appends <table> into <body>
body.appendChild(tbl);
// sets the border attribute of tbl to 2;
tbl.setAttribute("border", "1");
}
}
xhr.open("GET","fstatus.php",true);
xhr.send(null);
}
</script>
</head>
<body>
<h1> Create an Item </h1>
<form method="post">
<table align="center" border = "2" cellspacing ="0" cellpadding="3" id="table">
<tr><td><b>Functionality Name:</b></td> <td><b>Description:</b></td> <td><b>Status:</b></td> <td><input type="submit" Name= "Ajouter" Value="Ajouter" onclick="go()"></a></td></tr>
</table>
</form>
</body>
</html>
Je teste sur IE et aucun resultat. Je clique Ajouter mais rien ne semble se passer.
Merci
]]>
<?php
require_once ('../mysqli_connect.php');
// Retrieve all the statuses of a functionality
$q = "SELECT F_status_ID, Functionality_status FROM fstatuses ORDER BY F_status_ID ASC";
$r = mysqli_query($dbc, $q);
if (mysqli_num_rows($r) > 0) {
while ($menu_row = mysqli_fetch_array($r, MYSQLI_NUM)) {
echo "<option value=\"$menu_row[0]\">$menu_row[1]</option>\n";
}
}
mysqli_free_result($r);
unset($menu_row);
?>
</select>
</td>
<td> <textarea name="fdescription" rows="2" cols="30" wrap="hard" ></textarea> </td>
<td valign="center"><a href="delete.php">[delete]</a></td>
</tr>
Si j'enleve les <tr> et <td> qui sont la, comment je vais faire pour deliminter les differentes cellules?
J;ai 4 cellules:
- la 1ere cellule est une zone de texte
- la 2eme un textarea
-la 3eme, une liste deroulante
- la 4eme un href
J'utilise <td> pour les separer. Si j'enleve le <td> comment ferais pour les separer?
Merci
]]>j'ai deja lu ce tuto. la difference est que le xhr.responseText que j'ai, a deja les balises <tr> et <td>.
Donc je ne peux plus utiliser ce tutoriel. une autre solution?
Oui, modifier ce qui génère ton xhr.responseText.
]]>Donc je ne peux plus utiliser ce tutoriel. une autre solution?
Merci
]]>Merci
]]>