<body>
<form id="form1" name="form1" method="post" action="">
  <label>
  <input type="text" name="text1" id="text1"/>
  <select name="select" id="select">
  <option value="add">+</option>
   <option value="minus">-</option>
    <option value="multiply">*</option>
  <option value="divide">/</option></select>
  <input type="text" name="text2" id="text2"/>
  <input name="equel" type="button" id="equel"  onclick="count()" value="="/>
  <input type="text" name="text3" id="text3"/>
  </label>
</form>
</body>
</html>
<script language="javascript">
function count()
{
var text1 = document.getElementById("text1");
var text2 = document.getElementById("text2");
var text3 = document.getElementById("text3");
   var  = document.getElementById("select").value;
   if( == "add")
   text3 = parseInt(text1) + parseInt(text2) ;
   if( == "minus")
   text3 = parseInt(text1) - parseInt(text2) ;
   if( == "multiply")
   text3 = parseInt(text1) * parseInt(text2) ;
   if( == "divide")
   text3 = parseInt(text1) / parseInt(text2) ;}
</script>
大家帮忙看下为什么那个调用“count()”这个函数没有反应呢

解决方案 »

  1.   

    自己在count函数里用alert输出下提示定位错误行。
      

  2.   

    text1 = document.getElementById("text1").value;
    text3.value = ...
      

  3.   

    getElementById返回的是对象,你的用它的value值才行。
      if ( == "add")
          text3.value = parseInt(text1.value) + parseInt(text2.value) ;
      

  4.   

    小东西,firebug,ie开发工具逐步调试。
      

  5.   

    <html>
    <head>
        
        </head>
        <body>
    <form id="form1" name="form1" method="post" action="">
     
      <input type="text" name="text1" id="text1"/>
      <select name="select" id="select">
      <option value="add">+</option>
      <option value="minus">-</option>
      <option value="multiply">*</option>
      <option value="divide">/</option></select>
      <input type="text" name="text2" id="text2"/>
      <input name="equel" type="button" id="equel" onclick="count()" value="="/>
      <input type="text" name="text3" id="text3"/></form>
    </body>
    </html>
    <script language="javascript">
    function count()
    {
    var text1 = document.getElementById("text1").value;
    var text2 = document.getElementById("text2").value;
    var text3 = document.getElementById("text3");
      var  = document.getElementById("select").value;
      if( == "add")
      text3.value = parseInt(text1) + parseInt(text2) ;
      if( == "minus")
      text3.value = parseInt(text1) - parseInt(text2) ;
      if( == "multiply")
      text3.value= parseInt(text1) * parseInt(text2) ;
      if( == "divide")
      text3.value= parseInt(text1) / parseInt(text2) ;}
    </script>
        </body>
    <html>