代码如下
<html><head><title>计算器</title>
<style type="text/javascript">
var a,b,c,e;
function qq(){
document.getElementByid("a").value=a;
document.getElementByid("b").value=b;
document.getElementByid("c").value=c;
e=(((a*1)+(b*1))*c)/2;
document.getElementByid("e").value=e;
}</style>
</head><body>
<h2>梯形面积计算</h2>
<p>上底:<input style="text" id="a"/></p>
<p>下底:<input style="text" id="b"/></p>
<p>高:&nbsp&nbsp<input style="text" id="c"/></p>
<input type="button" value="计算"  onclick="qq()"/>
<p>面积:<input style="text" id="e"/></p>
</body></html>
提示错误:属性'qq'的值为null、未定义或不是function对象
在线等大神讲解!!!

解决方案 »

  1.   

    <html><head><title>计算器</title>
    <script type="text/javascript">
    var a,b,c,e;
    function qq(){
    a=document.getElementById("a").value;
    b=document.getElementById("b").value;
    c=document.getElementById("c").value;
    e=(((a*1)+(b*1))*c)/2;
    document.getElementById("e").value=e;
    }</script>
    </head><body>
    <h2>梯形面积计算</h2>
    <p>上底:<input style="text" id="a"/></p>
    <p>下底:<input style="text" id="b"/></p>
    <p>高:&nbsp&nbsp<input style="text" id="c"/></p>
    <input type="button" value="计算"  onclick="qq()"/>
    <p>面积:<input style="text" id="e"/></p>
    </body></html>
    你可以先找一点比较基础的书看看  javascript权威指南  建议看下