J'essaye de faire disparaître un "td" à chaque fois que la date est antérieure à cette date (dans le passé). Mais ce qui se passe est que seule la première colonne est affectée alors que les autres ne le sont pas.Comment faire un javascript affecte toutes les valeurs d'un tableau
<script type="text/javascript">
//<![CDATA[
function vanish() {
downloadUrl("bckendcommmap.php", function(data) {
var xml = data.responseXML;
var markers50 = xml.documentElement.getElementsByTagName("marker50");
// Split timestamp into [ Y, M, D, h, m, s ]
for (var i = 0; i < markers50.length; i++) {
var newdate = markers50[0].getAttribute("date");
var trainid = markers50[0].getAttribute("trainingid");
var t = newdate.split(/[- :]/);
// Apply each element to the Date function
var d = new Date(t[0], t[1]-1, t[2]);
alert(d);
var rightNow = new Date();
var trainingDate = new Date(d);
if (rightNow < d) {
document.getElementById("assess").innerHTML = ""; /* make it disappear */
}
else if (rightNow > d) {
document.getElementById("edit").innerHTML = "";
}
// -> Wed Jun 09 2010 13:12:01 GMT+0100 (GMT Daylight Time)
}
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]>
</script>
Voici parties de la table et td:
<body onload="vanish();">
<table id="gradient-style" width="290" border="0" cellspacing="0" cellpadding="0" >
<thead>
<tr>
<td align="center"><strong> Training Name</strong></td>
<td align="center"><strong> Description</strong></td>
<td align="center"><strong> Location</strong></td>
<td align="center"><strong> Date</strong></td>
<td align="center"><strong> Time Start</strong></td>
<td align="center"><strong> Time End</strong></td>
<td align="center"><strong> Capacity</strong></td>
<td align="center" colspan="2"><strong>Actions</strong></td>
</tr>
</thead>
<?php
while($rows=mysql_fetch_array($get)){
?>
<tbody>
<tr>
<td><?php echo $rows['title']; ?></td>
<td><?php echo $rows['description']; ?></td>
<td><?php echo $rows['location']; ?></td>
<td><?php echo $rows['date']; ?></td>
<td><?php echo $rows['start']; ?></td>
<td><?php echo $rows['end']; ?></td>
<td><?php echo $rows['capacity']; ?></td>
**<td align="center"><div id="edit"><a href="TrainingUpdate.php?id=<?php echo $rows['trainingid']; ?>">Edit</a></div></td><td align="center"><div id="assess"><a href="Training_Assessment.php?id=<?php echo $rows['trainingid']; ?>">Assess Training</a></div></td>**
</tr>
</tbody>
<?php
}
?>
</table>
</body>
Cette ligne est le td que je suis en train de disparaître en ce qui concerne la date:
<td align="center"><div id="edit"><a href="TrainingUpdate.php?id=<?php echo $rows['trainingid']; ?>">Edit</a></div></td><td align="center"><div id="assess"><a href="Training_Assessment.php?id=<?php echo $rows['trainingid']; ?>">Assess Training</a></div></td>
Vous pourriez améliorer vos chances d'obtenir une réponse en posant une question plus précise et en nous donnant une idée de ce que vous avez essayé ou de ce que vous pensez être le problème. "Voici du code et trouvez ça pour moi" n'est pas vraiment ce que c'est. Essayez - J'ai une table qui est générée dynamiquement côté serveur. Dans chaque rangée il y a un bouton d'édition. Quand on clique dessus, je veux que X arrive. Mais les choses vont mal ... où? – mrtsherman