1

次のコードがあります。

<script>
    var interval;
    var minutes = 0;
    var seconds = 5;

   function countdown(element) {
        interval = setInterval(function() {
            var el = document.getElementById(element);
            if(seconds == 0) {
                if(minutes == 0) {
                    el.innerHTML = "<a href=http://www.parkho.ir/phpvms/admin/index.php/aircraftmanager/update>Hello</a>";                    
                    clearInterval(interval);
                    return;
                } else {
                    minutes--;
                    seconds = 60;
                }
            }
            if(minutes > 0) {
                var minute_text = minutes + (minutes > 1 ? ' minutes' : ' minute');
            } else {
                var minute_text = '';
            }
            var second_text = seconds > 1 ? 'seconds' : 'second';
            el.innerHTML = minute_text + ' ' + seconds + ' ' + second_text + ' remaining';
            seconds--;
        }, 1000);
    }
    </script>
<h3><?php echo $title ;?></h3>
<head>
    <link rel="stylesheet" href="./css/style.css" type="text/css" />
    <script type="text/javascript" src="<?php echo fileurl('lib/js/jquery-1.3.1.min.js');?>"></script>
    <script type="text/javascript" src="<?php echo fileurl('lib/js/jquery.tablesorter.js');?>"></script>
    <script type="text/javascript" src="<?php echo fileurl('lib/js/jquery.tablesorter.pager1.js');?>"></script>
</head>
<body>
<div align="left" id="pager" class="pager">
    <table width="50%" align="center">
    <form>
        <tr>
            <td align="center"><img src="<?php echo fileurl('lib/images/first.png');?>" class="first"/>
            <img src="<?php echo fileurl('lib/images/prev.png');?>" class="prev"/></td>
            <td align="center"><input width="5" valign="top" type="text" class="pagedisplay"/></td>
            <td align="center"><img src="<?php echo fileurl('lib/images/next.png');?>" class="next"/>
            <img src="<?php echo fileurl('lib/images/last.png');?>" class="last"/></td>
            <td align="center"><select class="pagesize">
                                <option value="10">5 per page</option>
                                <option value="20">10 per page</option>         
                                <option value="50">25 per page</option>         
                               </select>
            </td>
        </tr>
    </form>
    </table>
</div>
<script defer="defer">
    $(document).ready(function() 
    { 
        $("#insured_list")
        .tablesorter({widthFixed: true, widgets: ['zebra']})
        .tablesorterPager({container: $("#pager")}); 
    } 
    ); 
</script>
<table id="insured_list" align="center" border="1" width="100%" cellpadding="0" cellspacing="0">
<thead>
    <th align="center" colspan="10"><font color="black" size="6"><b>Aircraft Manager</b></font></th>
        <tr>
            <td align="left" colspan="0"><a href="<?php echo adminurl('/aircraftmanager/allac?available=0') ;?>"><input type="button" value="Inactive All Aircraft"></a></td>
            <td align="left" colspan="0"><a href="<?php echo adminurl('/aircraftmanager/allac?available=1') ;?>"><input type="button" value="Active All Aircraft"></a></td>
            <td align="left" colspan="0"><a href="<?php echo adminurl('/aircraftmanager/update') ;?>"><input type="button" value="Update Status"></a></td>
            <td align="left" colspan="0"><a href="<?php echo adminurl('/aircraftmanager/status?available=100') ;?>"><input type="button" value="Reset Status"></a></td>
        </tr>
        <tr>
            <td align="center"><b>ID</b></td>
            <td align="center"><b>Name</b></td>
            <td align="center"><b>Registration</b></td>
            <td align="center"><b>Location</b></td>
            <td align="center"><b>Status</b></td> 
            <td align="center"><b>Time</b></td> 
            <td align="center" colspan="2"><b>Options</b></td>          
        </tr>
</thead>
<tbody)
<?php
$i=0;
foreach($aircrafts as $aircraft)
{
$air = AManagerData::getaircraftdetail($aircraft->id);
?>
    <tr>
            <td align="center"><?php echo $aircraft->id ;?></td>
            <td align="center"><?php echo $aircraft->fullname ;?></td>
            <td align="center"><?php echo $aircraft->registration ;?></td>
            <td align="center">
            <?php 
            $location = AManagerData::getaircraftlocation($aircraft->id);
            echo $location->arricao;
            ?>
            </td>
            <td align="center">
            <?php
            $param = AManagerData::getaircraftparam($aircraft->id);
            $stat = $param->start;
            echo $stat.'%';
            ?>
            </td>
            <td align="center">
            <div id='countdown'></div>
            </td>           
            <td align="center">
            <a class="{button:{icons:{primary:'ui-icon-arrowthick-1-s'}}}" href="#" onclick="$('#details_dialog_<?php echo $aircraft->id;?>').toggle()"><input type="button" Value="Parameters"></a>
            </form>
            </td>
            <td align="center">
            <?php
            if(PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) 
                {
                    $pilotid = $pilot->pilotid;
            ?>
            <form id="deletepilot" method="get" action="<?php echo adminurl('/pilotmanager/deletePilot');?>">
            <input type="hidden" name="pilotid" value="<?php echo $pilotid ;?>" />
            <input type="submit" name="submit" value="Delete" onclick="return doublecheck()" ;?>
            </form>
            <?php
                }
            ?>
            </td>

        </tr>
        <tr>
            <td colspan="10">
                <form action="<?php echo adminaction('/aircraftmanager/param');?>" method="GET">
                <table align="center" border="0" id="details_dialog_<?php echo $aircraft->id;?>" style="display:none"  width="100%">
                    <tr>
                        <th align="center" bgcolor="black" colspan="0"><font color="white">Aircraft Parameter Setting</font></th>
                    </tr>
                    <tr>
                        <td><b>&nbsp;Start:</b></td>
                        <td><input type="radio" name="perstart" value="100" checked="checked" >100%
                        <input type="radio" name="perstart" value="75" >75%
                        <input type="radio" name="perstart" value="50" >50%</td>

                        <td><b>&nbsp;Hard Landing:</b></td>
                        <td><input type="radio" name="perhard" value="30" checked="checked" >30%
                        <input type="radio" name="perhard" value="20" >20%
                        <input type="radio" name="perhard" value="15" >15%</td>
                    </tr>
                    <tr>
                        <td><b>&nbsp;Smooth Landing:</b></td>
                        <td><input type="radio" name="persoft" value="2" checked="checked" >2%
                        <input type="radio" name="persoft" value="4" >4%
                        <input type="radio" name="persoft" value="10" >10%</td>

                        <td><b>&nbsp;Before Inactivity:</b></td>
                        <td><input type="radio" name="perhour" value="800" checked="checked" >800 hrs
                        <input type="radio" name="perhour" value="600" >600 hrs
                        <input type="radio" name="perhour" value="400" >400 hrs</td>
                    </tr>
                    <tr>
                        <td><b>&nbsp;Maintenance Period:</b></td>
                        <td><input type="radio" name="mhours" value="12" checked="checked" >12 hrs
                        <input type="radio" name="mhours" value="24" >24 hrs
                        <input type="radio" name="mhours" value="36" >36 hrs</td>

                        <td><b>&nbsp;Maximum Landing Rate:</b></td>
                        <td><input type="radio" name="maxlr" value="-600" checked="checked" >600 ft/m
                        <input type="radio" name="maxlr" value="-450" >450 ft/m
                        <input type="radio" name="maxlr" value="-300" >300 ft/m</td>
                    </tr>
                    <tr><td colspan="4"><hr></td></tr>
                    <tr>
                    <td colspan="0" align="center"><input type="hidden" name ="aircraft" value="<?php echo $aircraft->id ;?>"><input type="submit" value="Apply Settings"></td>
                    </tr>
                </table>
                </form>
            </td>
        </tr>

<?php
}

?>

<script type="text/javascript">
function doublecheck()
{
    var answer = confirm("Are you sure you want to delete the aircraft?")
    if (answer) {
        return true;
    }

    return false;
}
</script>
</tbody>
</table>
</body>

私がやろうとしているのは、foreach() ループでカウントダウン タイマーを表示することですが、最初のレコードのみがタイマーを表示し、残りは空白で表示されます。これは、タイマーを表示する行です。

<td align="center">
            <div id='countdown'></div>
            </td>           

どこが間違っているか、またはこの方法で実行可能かどうか教えてください。ありがとう

4

0 に答える 0