Php 如何使javascript影响表中的所有值

Php 如何使javascript影响表中的所有值,php,javascript,Php,Javascript,我试图让一个“td”在今天(过去)之前的日期消失。但是现在发生的是,只有第一列受到影响,而其他列没有受到影响 <script type="text/javascript"> //<![CDATA[ function vanish() { downloadUrl("bckendcommmap.php", function(data) { var xml = data.responseXML; var markers50 = xml.do

我试图让一个“td”在今天(过去)之前的日期消失。但是现在发生的是,只有第一列受到影响,而其他列没有受到影响

 <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>

//(d){
document.getElementById(“编辑”).innerHTML=“”;
}
//->2010年6月9日星期三13:12:01 GMT+0100(GMT昼间)
}
});
}
函数下载url(url,回调){
var请求=window.ActiveXObject?
新的ActiveXObject('Microsoft.XMLHTTP'):
新的XMLHttpRequest;
request.onreadystatechange=函数(){
if(request.readyState==4){
request.onreadystatechange=doNothing;
回调(请求、请求、状态);
}
};
打开('GET',url,true);
请求发送(空);
}
函数doNothing(){}
//]]>
以下是表格和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>

培训名称
说明
位置
日期
时间开始
时间结束
容量
行动
****
这一行是我试图消除的关于日期的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>

您仅隐藏
div
,如果要隐藏
td
请尝试以下操作:

**<td id="edit" align="center"><div><a href="TrainingUpdate.php?id=<?php echo $rows['trainingid']; ?>">Edit</a></div></td><td id="assess" align="center"><div><a  href="Training_Assessment.php?id=<?php echo $rows['trainingid']; ?>">Assess Training</a></div></td>**


很难判断页面中生成的完整HTML是什么样子,但是您是否意识到,在一个具有给定ID的网页中只能有一个对象。因此,不能有多个具有
ID=“assessment”
的对象。如果这就是您正在做的,那么getElementById很可能只返回第一个——尽管确切的行为没有定义,因为它不是有效的HTML

第二,为什么不使用CSS来隐藏东西,而不是清除内部HTML呢。例如,您可以使用
class=“assessment”
而不是
id=“assessment”
。然后创建如下CSS规则:

.triggerHide .assess {display: none;} 

然后,当您想要隐藏表中的所有评估类时,只需将类“triggerHide”添加到表中即可。砰的一声,表中所有包含类assessment的对象都将隐藏。

您可以通过提出更具体的问题,以及让我们了解您尝试过的内容或您认为可能存在的问题,来提高获得答案的机会。“这里有一些代码,请帮我解决这个问题”并不是真正意义上的SO。Try-我有一个在服务器端动态生成的表。每行中都有一个编辑按钮。当它被点击时,我希望X发生。但是事情出了问题。。。。哪里
/*  Code... */
if (rightNow < d ) {  
var i = 0;  
while(document.getElementById("assess" + i) != null) {
document.getElementById("assess").innerHTML = ""; /* make it disappear */  
i++;
}
/* Code.../
.triggerHide .assess {display: none;}