十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
onclick="return scoref(f1)"
創(chuàng)新互聯(lián)專注于西工網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供西工營銷型網(wǎng)站建設(shè),西工網(wǎng)站制作、西工網(wǎng)頁設(shè)計、西工網(wǎng)站官網(wǎng)定制、微信小程序服務(wù),打造西工網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供西工網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
script language="JavaScript"
function scoref(f1) {
var score=0;
if(f1.R1.value=="產(chǎn)品觀念") score++;
if(f1.R2.value=="集中策略") score++;
if(f1.a1.value=="廣告") score++;
if(f1.a2.value=="滲透定價") score++;
if(f1.a3.value=="同心多角化") score++;
if(f1.組合.value=="寬度"+"長度"+"深度"+"關(guān)聯(lián)性") score++;
if(f1.市場.value=="消費(fèi)者市場"+"生產(chǎn)者市場") score++;
alert("你的成績?yōu)?"+score);
}
/script
注意:
如果下邊這段代碼有問題的話也不行
if(f1.R1.value=="產(chǎn)品觀念") score++;
if(f1.R2.value=="集中策略") score++;
if(f1.a1.value=="廣告") score++;
if(f1.a2.value=="滲透定價") score++;
if(f1.a3.value=="同心多角化") score++;
if(f1.組合.value=="寬度"+"長度"+"深度"+"關(guān)聯(lián)性") score++;
if(f1.市場.value=="消費(fèi)者市場"+"生產(chǎn)者市場") score++;
自己研究吧
你好,我給你寫了一個非常簡便且有效的代碼,不用針對每一個radio都添加onclick事件
script
function setResult(){
var obj=event.srcElement;
if(obj.tagName=="INPUT"){
document.getElementById("result").value=obj.value;
}
}
/script
div onclick="setResult();"
input type="radio" name="score" value="1"1分
input type="radio" name="score" value="2"2分
input type="radio" name="score" value="3"3分
input type="radio" name="score" value="4"4分
input type="radio" name="score" value="5"5分
/div
p得分input type="text" id="result"/p
給一個選手打分、去掉一個最高分、去掉一個最低分求平均得分和去掉兩個分。
思路:
1.創(chuàng)建五名選手,放到vector中。
2.遍歷vector容器,取出每一位選手,執(zhí)行for循環(huán),可以把10位評委的打分放到的deque中。
3.sort對deque中的分?jǐn)?shù)進(jìn)行排序,去掉最高分和最低分。
4.deque遍歷一遍,累加總分。
5.求平均值。
可以存到cookies中,也可以保存到服務(wù)器上,建議保存到服務(wù)器上,因?yàn)閏ookies可能會被刪除~如果你手機(jī)端的話還有一個本地存儲,就是HTML5的localStorage,你可以看一下具體的操作,不過也可以刪除,跟cokies一樣,只是保存的位置不同。可保存的數(shù)據(jù)大了一些而已~
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title新建網(wǎng)頁 1/title
script type="text/javascript"
function Click(){
if(document.forms[0].checkbox1.checked==truedocument.forms[0].checkbox2.checked==true){
document.forms[0].checkbox1Value.value="¥"+2980*0.9;
document.forms[0].checkbox2Value.value="¥"+1860*0.9;
}
}
/script
/head
body
form id="form1"
input type=checkbox id="checkbox1" onclick="Click()"input type="text" name="checkbox1Value" value="¥2980"p
input type=checkbox id="checkbox2" onclick="Click()"input type="text" name="checkbox2Value" value="¥1860"
/form
/body
/html
復(fù)選框后面不會帶什么值的,本身起的也就是個標(biāo)記的作用。
后面可以跟label,text之類的任何能顯示值的控件。
看著給分吧。
瀏覽器之爭,樓主試試不用上面的方法判斷,你給radio和checkbox賦個id比如id="q01",不用form,因?yàn)橐獙?shí)現(xiàn)全瀏覽器的兼容,用document.getElementById("q01").checked==true來判斷并加分,試試吧。
給你一段實(shí)驗(yàn)代碼。
html
head
script language="javascript"
function chk()
{
var point = 0;
if (document.getElementById("a1").checked == true)
{
point+=5;
}
if (document.getElementById("b1").checked == true document.getElementById("b2").checked == true)
{
point+=5;
}
alert("你的得分:" + point);}
/script
/head
body
第一題,選擇A為正確答案
A.input id="a1" type="checkbox" value="checkbox" /
B.input id="a2" type="checkbox" value="checkbox" /
C.input id="a3" type="checkbox" value="checkbox" /
D.input id="a4" type="checkbox" value="checkbox" /
第二題,選擇AB為正確答案
A.input id="b1" type="checkbox" value="checkbox" /
B.input id="b2" type="checkbox" value="checkbox" /
C.input id="b3" type="checkbox" value="checkbox" /
D.input id="b4" type="checkbox" value="checkbox" /
input type="button" name="Submit" value="提交" onclick="chk()" /
/body
/html