使用JavaScript更改基于另一个单元格的一个单元格的时间值

时间:2014-01-29 17:16:07

标签: javascript date time cell

我想在下面的示例代码中输入mytable1的Time值,并在mytable2中反映-7小时。考虑到时间范围是00:00 - 23:59也是关键。

<table width=600px id="mytable1">
    <tr>
        <td>GMT</td>
        <td>Monday</td>
        <td>Tuesday</td>
        <td>Wednesday</td>
        <td>Thursday</td>
        <td>Friday</td>
    </tr>
    <tr>
        <td>Person A</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
    </tr>
    <tr>
        <td>Person B</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
    </tr>
</table>
<br />
<table width=600px id="mytable2">
    <tr>
        <td>GMT-7</td>
        <td>Monday</td>
        <td>Tuesday</td>
        <td>Wednesday</td>
        <td>Thursday</td>
        <td>Friday</td>
    </tr>
    <tr>
        <td>Person A</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
    </tr>
    <tr>
        <td>Person B</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
        <td>17:00 - 01.30</td>
        <td>09:00 - 17.30</td>
    </tr>
</table>
<br />

1 个答案:

答案 0 :(得分:0)

<html>
<head>
<script>
function cd(val){
 var a = document.getElementById(val.id).value-7;
 document.getElementById("to").value=a;alert(a);
}    
</script>
</head>
<body>
<input type="text" name ="dat" id="fu" onChange="cd(this)"/>
<input type="text" name ="dat" id="to"/>
</body>
</html>

Possibly this can help you. Substitute all your table values accordingly