第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

請大神們幫我瞧瞧哪兒錯了以至于運行沒有反應(yīng),謝謝!

<!DOCTYPE html>

<html>

?<head>

? <title> 事件</title> ?

? <script type="text/javascript">

? ?function count(){

? ? var txt1,txt2,fruit,select;

? ? txt1=document.getElementById("txt1").value;

? ? txt2=document.getElementById("txt2").value;

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

? ? switch(select){

? ? ? ? case "+":

? ? ? ? ? ? fruit=parselnt(txt1)+parselnt(txt2);

? ? ? ? ? ? break;

? ? ? ? case "-":

? ? ? ? ? ? fruit=parselnt(txt1)-parselnt(txt2);

? ? ? ? ? ? break;

? ? ? ? case "*":

? ? ? ? ? ? fruit=parselnt(txt1)*parselnt(txt2);

? ? ? ? ? ? break;

? ? ? ? default:

? ? ? ? ? ? fruit=parselnt(txt1)/parselnt(txt2);

? ? }

? ? document.getElementById("fruit").value=fruit;?

? ?}

? </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()"/> <!--通過 = 按鈕來調(diào)用創(chuàng)建的函數(shù),得到結(jié)果-->?

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

?</body>

</html>


正在回答

7 回答

parselnt應(yīng)該寫成“”parseInt“”是大寫的i,不是l

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

程序媛ing 提問者

謝謝,不過改了之后仍然不能成功運行呢?
2016-07-21 回復(fù) 有任何疑惑可以回復(fù)我~

http://img1.sycdn.imooc.com//579466d7000189e008920568.jpg請看下!

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

程序媛ing 提問者

謝謝!
2016-07-29 回復(fù) 有任何疑惑可以回復(fù)我~

這個就正確了,原來的錯誤原因:parsetInt的大寫的i寫成了小寫的l;變量名不能和ID一樣。

<!DOCTYPE html>

<html>

?<head>

? <title> 事件</title> ?

? <script type="text/javascript">

? ?function count(){

? ? var a,b,num,c;

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

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

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

? ? switch(c){

? ? ? ? case "+":

? ? ? ? ? ? num=parseInt(a)+parseInt(b);

? ? ? ? ? ? break;

? ? ? ? case "-":

? ? ? ? ? ? num=parseInt(a)-parseInt(b);

? ? ? ? ? ? break;

? ? ? ? case "*":

? ? ? ? ? ? num=parseInt(a)*parseInt(b);

? ? ? ? ? ? break;

? ? ? ? default:

? ? ? ? ? ? num=parseInt(a)/parseInt(b);

? ? }

? ? document.getElementById("fruit").value=num;?

? ?}

? </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()"/> <!--通過 = 按鈕來調(diào)用創(chuàng)建的函數(shù),得到結(jié)果-->?

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

?</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

weibo_考早營_03695159

我試了你之前的可以啊,和修改變量名沒關(guān)系
2016-07-24 回復(fù) 有任何疑惑可以回復(fù)我~
#2

程序媛ing 提問者 回復(fù) weibo_考早營_03695159

o- -o
2016-07-24 回復(fù) 有任何疑惑可以回復(fù)我~

你的變量命名有問題,最后的輸出fruit可以換個變量名字試試,比如num輸出可以這樣寫:

document.getElementById("fruit").value=num;?//將num的值賦與fruit(輸出框)

同時,你的switch里面的變量都要改正

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

程序媛ing 提問者

對對對,改了之后就好了誒。厲害!可是不知道為什么
2016-07-22 回復(fù) 有任何疑惑可以回復(fù)我~

我擦,我都測試過了居然不是最佳答案,心碎呀...

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

程序媛ing 提問者

那你下次再回答我的問題我一定給你最佳啊~
2016-07-22 回復(fù) 有任何疑惑可以回復(fù)我~

fruit改成result

0 回復(fù) 有任何疑惑可以回復(fù)我~

parseInt才對你現(xiàn)在寫錯了

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

請大神們幫我瞧瞧哪兒錯了以至于運行沒有反應(yīng),謝謝!

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號