出不來(lái)結(jié)果,求解???
function count(){
????? var a=document.getElementById("txt1").value;
????? var b=document.getElementById("txt2").value;
???? ?
????? a=parselnt(a);
????? b=parselnt(b);
????? var c=document.getElementById("select").value;
????? var d;
????? switch(c){
????????? case "+":d=a+b;break;
????????? case "-":d=a-b;break;
????????? case "*":d=a*b;break;
????????? case "/":d=a/b;break;
????????? default:
????? }
????? document.getElementById("fruit").value=d;
?? }
? </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()"/> <!--通過(guò) = 按鈕來(lái)調(diào)用創(chuàng)建的函數(shù),得到結(jié)果-->
?? <input type='text' id='fruit' />??
2016-08-09
parseInt ?這個(gè)單詞寫(xiě)錯(cuò)了,中間那個(gè)是大寫(xiě)的i 不是小寫(xiě)的l
2016-08-09
學(xué)習(xí)來(lái)了