【发布时间】:2014-10-13 08:39:55
【问题描述】:
这是我的脚本:
<script type="text/javascript">
function getTimeStamp() {
var now = new Date();
return ( + now.getHours() + ':'
+ ((now.getMinutes() < 10) ?
("0" + now.getMinutes()) : (now.getMinutes())) +
':' + ((now.getSeconds() < 10) ? ("0" + now
.getSeconds()) : (now.getSeconds())));
}
function setTime() {
document.getElementById('field').value = getTimeStamp();
}
</script>
HTML 代码: 频率 运行时间表 期间 服务水平协议 类型 标题 实际开始 实际结束 评论 完成人
<th align="center">
</th>
</tr>
</thead>
<table>
td align="center"><?php echo $row['frequency']?></td>
<td align="center"><?php echo $row['rts']?></td>
<td align="center"><?php echo $row['duration']?></td>
<td align="center"><?php echo $row['sla']?></td>
<td align="center"><?php echo $row['type']?></td>
<td align="center"><?php echo $row['title']?></td>
<td>
<input id="field" type="text" name="field" value="" readonly size="11" />
<button type="button" onclick="setTime();">Get Time</button>
</td>
</table>
我想通过按下函数上的按钮在每一行添加一个实际的开始时间和结束时间,但问题是只有第一个字段只输出时间,当我按下其他列上的获取时间时没有任何反应行。
【问题讨论】:
-
信息不足,无法提供帮助。请添加显示您发布到 PHP 文件的方式/位置/内容的代码。并发布 PHP 文件的相关部分以解析所述数据并将其发布到数据库。
-
“id”属性在页面上必须是唯一的。您不能多次使用 ID。你需要为此使用一个类。
标签: javascript php mysql