还是不行啊

来源:6-11 编程练习

新人沈琦斌

2016-04-10 18:27

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

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

<!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>

我是不是没救了?

写回答 关注

4回答

JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

467160 学习 · 21875 问题

查看课程

相似问题