问答详情
源自:6-11 编程练习

还是不行啊

实践练习还是不行,没有结果啊。

求求各位大神帮我看看这段代码哪里出问题了,我快崩溃了。

<!DOCTYPE html>

<html>

 <head>

  <title> 事件</title>  

  <script type="text/javascript">

   function count(){

       var a,b,c,d;

       a=parseInt(document.getElementById("txt1").value);

       b=parseInt(document.getElementById("txt2").value);

       c=document.getElementById("select").value;

       

       switch(c){

       case"+":

       d=a+b;

       break;

       case"-":

       d=a-b;

       break;

       case"*":

       d=a*b;

       break;

       case"/":

       d=a/b;

       break;}

       d=document.getElementById("fruit").value

       }

</script> 

 </head> 

 <body>

   <input type='text' id='txt1' /> 

   <select id='select'>

<option value='+'>+</option>

<option value="-">-</option>

<option value="*">*</option>

<option value="/">/</option>

   </select>

   <input type='text' id='txt2' /> 

   <input type='button' value=' = ' onclick="count()"/> <!--通过 = 按钮来调用创建的函数,得到结果--> 

   <input type='text' id='fruit' />   

 </body>

</html>

我是不是没救了?

提问者:新人沈琦斌 2016-04-10 18:27

个回答