dongpo1216 2013-12-28 02:45
浏览 1034
已采纳

HTML表格向右移动

I'm new to HTML and am wondering what the best practice is to structure a calculator that I'm coding. For example, When pressing the "calculate" button, all of the input forms shift to the right. How can I keep everything still?

http://rgoo.co/calculators/bmr-calculator.php

<?php
$answer = "";
$agev = "";
$feetv = "";
$inchesv = "";
$weightv = "";

if (isset($_POST['agev']) && isset($_POST['feetv']) && isset($_POST['inchesv']) && isset($_POST['weightv'])) {
    $agev = $_POST['agev'];
    $feetv = $_POST['feetv'];
    $inchesv = $_POST['inchesv'];
    $weightv = $_POST['weightv'];

    $totalheightv = $inchesv + ($feetv*12);
    $answer = 66 + (6.23*$weightv) + (12.7*$totalheightv) - (6.8*$agev);

}

echo <<<_END
<form method='post' action=''>
<table border='0' width='500px' cellpadding='2' cellspacing='1' class="table">
<tr class="calcheading"><td colspan="4" align="left"><strong>IIFYM test</strong></td></tr>
<tr class="calcrow"><td>Age:</td><td align="justify"><input type='text' name='agev' value="$agev"/>Years</td></tr>
<tr class="calcrow2"><td>Height:</td><td align="justify"><input type='text' name='feetv' value="$feetv"/>Ft<input type='text' name='inchesv' value="$inchesv"/>In</td></tr>
<tr class="calcrow"><td>Weight:</td><td align="left"><input type='text' name='weightv' value="$weightv"/>lbs</td></tr>
<tr class="submit"><td colspan="2"><input type='submit' value='Calculate'/></td></tr>
_END;
?>

<tr class="calcrow">
<td>Your BMR is: <?php echo $answer?></td>


</tr>
</table>
</form>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BMR Calculator</title>
</head>

<body>
BMR = Basal Metabolic Rate (similar to RMR = Resting Metabolic Rate. Your BMR is represents the number of calories your body burns at rest. Regular routine of cardiovascular exercise can increase your BMR, improving your health and fitness when your body's ability to burn energy gradually slows down.


</body>
</html>
  • 写回答

2条回答 默认 最新

  • dongyao2022 2013-12-28 02:48
    关注

    Try adding colspan="2" to <td>Your BMR is: <?php echo $answer?></td>

    Also, format your HTML correctly!

    <?php
    $answer = "";
    $agev = "";
    $feetv = "";
    $inchesv = "";
    $weightv = "";
    if(isset($_POST['agev']) && isset($_POST['feetv']) && isset($_POST['inchesv']) && isset($_POST['weightv'])) {
        $agev = $_POST['agev'];
        $feetv = $_POST['feetv'];
        $inchesv = $_POST['inchesv'];
        $weightv = $_POST['weightv'];
    
        $totalheightv = $inchesv + ($feetv*12);
        $answer = 66 + (6.23*$weightv) + (12.7*$totalheightv) - (6.8*$agev);
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>BMR Calculator</title>
    </head>
    <body>
    <form method='post' action=''>
    <table border='0' width='500px' cellpadding='2' cellspacing='1' class="table">
        <tr class="calcheading">
            <td colspan="2" align="left"><strong>IIFYM test</strong></td>
        </tr>
        <tr class="calcrow">
            <td>Age:</td>
            <td align="justify"><input type='text' name='agev' value="<?php echo $agev; ?>"/>Years</td>
        </tr>
        <tr class="calcrow2">
            <td>Height:</td>
            <td align="justify"><input type='text' name='feetv' value="<?php echo $feetv; ?>"/>Ft<input type='text' name='inchesv' value="<?php echo $inchesv; ?>"/>In</td>
        </tr>
        <tr class="calcrow">
            <td>Weight:</td>
            <td align="left"><input type='text' name='weightv' value="<?php echo $weightv; ?>"/>lbs</td>
        </tr>
        <tr class="submit">
            <td colspan="2"><input type='submit' value='Calculate'/></td>
        </tr>
        <tr class="calcrow">
            <td colspan="2">Your BMR is: <?php echo $answer?></td>
        </tr>
    </table>
    </form>
    
    BMR = Basal Metabolic Rate (similar to RMR = Resting Metabolic Rate. Your BMR is represents the number of calories your body burns at rest. Regular routine of cardiovascular exercise can increase your BMR, improving your health and fitness when your body's ability to burn energy gradually slows down.
    </body>
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么