首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >简单Javascript/HTML脚本的问题

简单Javascript/HTML脚本的问题
EN

Stack Overflow用户
提问于 2018-08-01 04:33:56
回答 4查看 203关注 0票数 2

不管我怎么修改代码,我总是收到一个错误。我已经写了几种不同的方式,但这里是一种方式。

我收到的错误是‘在id为’result‘的div中找不到发货费用’‘

UI约束:文件名应为index.html。计算运费使用(总运费charge=重量*成本)。有关详细规格,请参阅示例截图。

The code is suppose to look similar to

代码语言:javascript
运行
复制
<!DOCTYPE html>
<html>
    <head>
         <style>
                #header {
                    border: 1px solid lightgrey;
                    margin : -8px -8px 0;
                    background-color: lightgrey;
                 }
        </style>
</head>

<body>
    <div id="header">
        <table style="width:100%">
            <tr style="width:100%">
                <td style="width:20%">
                    <span>
                        <img align="left" src="logo.jpeg" width="120px" height="120px">
                    </span>
                </td>    
                <td style="width: 60%;">
                    <span>
                        <center>
                            <h1>DATAX Shipping Company</h1>
                        </center>
                    </span>
                </td>
                <td style="width: 40%; padding-bottom: 7%;padding-left:5%;">
                    <span>
                        <a href="#" id="signup">Sign up</a>
                        <a href="#" id="login" style="padding-left:30px">Log in</a>
                    </span>
                </td>
            </tr>
        </table>

            <!-- fill code here -->
            <center>
<h3>Calculation of Shipping charge</h3>
</center>
<form>
Total Product Weight <input type="text" id="weight" /><br>
Shipping cost (per kg) <input type="text" id="cost" /><br>
<input type="button" onClick="multiplyBy()" Value="Compute" id="compute" />
</form>
The Total Shipment charge is <div id="result"></div>


<script>
    function multiplyBy()
{
        num1 = document.getElementById("weight").value;
        num2 = document.getElementById("cost").value;
        document.getElementById("result").innerText = num1 * num2;
}
</script>
</body>
</html>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51621664

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档