| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1495 人关注过本帖
标题:关于js的循环判断问题
只看楼主 加入收藏
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
结帖率:88.89%
收藏
 问题点数:0 回复次数:5 
关于js的循环判断问题

 <SCRIPT language=JavaScript>
function processForm(form){

var j=0;
var count="";
var a = document.getElementsByTagName("INPUT");
for(var i=0; i<a.length; i++)
{
  if(a[i].type=="radio")
  {
    j++;
  }
}
count=j/3;//取出radio组数
//alert(count);

//判断每组radio
for(var i=1;i<count+1;i++)
{
var rs=document.getElementsByName("c"+i);
if(rs[0].checked==false&&rs[1].checked==false&&rs[2].checked==false)
{
alert("第"+i+"个没选择!");return false; }
}

var xf,hc1,hc2,hc3,hc4,hc5,hc6,hc7,hc8,hc9,hc10,hc11,hc12,hc13,hc14,hc15,hc16,hc17,hc18,hc19,hc20,hc21,hc22,hc23,hc24,hc25,hc26,hc27,hc28,hc29,hc30;
  xf=hc1=hc2=hc3=hc4=hc5=hc6=hc7=hc8=hc9=hc10=hc11hc12=hc13=hc14=hc15=hc16=hc17=hc18=hc19=hc20=hc21=hc22=hc23=hc24=hc25=hc26=hc27=hc28=hc29=hc30=1;
//loops through the radio buttons finding out which one is selectedand form.c2[0].checked!=true

if (form.c1[0].checked==1) hc1=3;
if (form.c1[1].checked==1) hc1=2;
if (form.c2[2].checked==1) hc2=3;
if (form.c2[1].checked==1) hc2=2;
if (form.c3[1].checked==1) hc3=3;
if (form.c3[2].checked==1) hc3=2;
if (form.c4[1].checked==1) hc4=3;
if (form.c4[2].checked==1) hc4=2;
if (form.c5[1].checked==1) hc5=3;
if (form.c5[2].checked==1) hc5=2;
if (form.c6[0].checked==1) hc6=3;
if (form.c6[1].checked==1) hc6=2;
if (form.c7[1].checked==1) hc7=2;
if (form.c7[2].checked==1) hc7=3;
if (form.c8[0].checked==1) hc8=2;
if (form.c8[1].checked==1) hc8=3;
if (form.c9[1].checked==1) hc9=2;
if (form.c9[2].checked==1) hc9=3;
if (form.c10[0].checked==1) hc10=3;
if (form.c10[2].checked==1) hc10=2;
if (form.c11[0].checked==1) hc11=2;
if (form.c11[1].checked==1) hc11=3;
if (form.c12[0].checked==1) hc12=2;
if (form.c12[2].checked==1) hc12=3;
if (form.c13[1].checked==1) hc13=3;
if (form.c13[2].checked==1) hc13=2;
if (form.c14[0].checked==1) hc14=2;
if (form.c14[2].checked==1) hc14=3;
if (form.c15[0].checked==1) hc15=3;
if (form.c15[2].checked==1) hc15=2;
if (form.c16[0].checked==1) hc16=2;
if (form.c16[1].checked==1) hc16=3;
if (form.c17[0].checked==1) hc17=3;
if (form.c17[2].checked==1) hc17=2;
if (form.c18[1].checked==1) hc18=3;
if (form.c18[2].checked==1) hc18=2;
if (form.c19[0].checked==1) hc19=3;
if (form.c19[1].checked==1) hc19=2;
if (form.c20[0].checked==1) hc20=2;
if (form.c20[1].checked==1) hc20=3;
if (form.c21[0].checked==1) hc21=3;
if (form.c21[2].checked==1) hc21=2;
if (form.c22[1].checked==1) hc22=3;
if (form.c22[2].checked==1) hc22=2;
if (form.c23[0].checked==1) hc23=3;
if (form.c23[2].checked==1) hc23=2;
if (form.c24[0].checked==1) hc24=2;
if (form.c24[1].checked==1) hc24=3;
if (form.c25[1].checked==1) hc25=3;
if (form.c25[2].checked==1) hc25=2;
if (form.c26[0].checked==1) hc26=3;
if (form.c26[2].checked==1) hc26=2;
if (form.c27[1].checked==1) hc27=3;
if (form.c27[2].checked==1) hc27=2;
if (form.c28[1].checked==1) hc28=3;
if (form.c28[2].checked==1) hc28=2;
if (form.c29[0].checked==1) hc29=3;
if (form.c29[1].checked==1) hc29=2;
if (form.c30[0].checked==1) hc30=2;
if (form.c30[1].checked==1) hc30=3;
xf=hc1+hc2+hc3+hc4+hc5+hc6+hc7+hc8+hc9+hc10+hc11+hc12+hc13+hc14+hc15+hc16+hc17+hc18+hc19+hc20+hc21+hc22+hc23+hc24+hc25+hc26+hc27+hc28+hc29+hc30;        
form.answer.value="+xf+";
if(form.hyzh.value == "")    {alert("会员帐号不能为空!");form.hyzh.focus();return false;}
if(form.hymm.value == "")    {alert("会员密码不能为空!");form.hymm.focus();return false;}
form.submit();

}
</SCRIPT>
 <link href="../newweb.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.bb{border:1px solid;border-color:#999999; height:14px; width:100px;
    color:#666666;
    font-size: 12px;}
.bb2{border:1px solid;border-color:#6595D6; height:60px; width:534px;
    color:#666666;
    font-size: 12px;}
-->
</style>
</HEAD>
<BODY leftMargin=0 topMargin=0>
<TABLE class=newfont cellSpacing=0 cellPadding=5 width="98%"align=center border=0>
                  <FORM name=form action="../qxlxsave.asp?lx=情绪类型测试" method="post">
  <TBODY>
    <TR height=1>
      <TD colSpan=3 height=25><DIV align=center class="skilltitle"><STRONG><FONT
                        size=4>情绪类型测试</FONT></STRONG> </DIV></TD>
    </TR>
    <TR>
      <TD bgColor=#f9fdf2 colSpan=3>答题前请先输入并确认会员身份(<span class="redfont">重要</span>):
        <iframe name="hiddenframe" border=0 height="15" width=0></iframe>      </TD>
    </TR>
        <TR>
      <TD width="38%" bgColor=#f9fdf2><table width="341" border="0" class="newfont">
        <tr>
          <td width="53" height="18" valign="middle">会员帐号</td>
          <td width="102"><input name="hyzh" type="text" class="bb" onBlur=window.open("hynamecheck.asp?id="+this.value,"hiddenframe")></td>
          <td width="66" valign="middle"><div align="center">会员密码</div></td>
          <td width="102"><input name="hymm" type="text" class="bb" onBlur=window.open("hymmcheck.asp?id="+this.value,"hiddenframe")></td>
        </tr>
        
      </table></TD>
      <TD colspan="2" bgColor=#f9fdf2><div id="namecheck" style="position:relative; width:150px; height:17px; z-index:0;border: 0px none #666666; visibility:hidden; left: 0px; top:0px;" class="redfont">会员名称正确!</div><div id="namecheck2" style="position:relative; width:150px; height:17px; z-index:0;border: 0px none #666666; visibility:hidden; left: 0px; top:0px;" class="redfont">会员名称错误!</div></TD>
    </TR>
    <TR>
      <TD colSpan=3>
        <TABLE border=0 cellPadding=8 cellSpacing=0 class="newfont">
          <TBODY>
          <TR>
      <TD height="34" colspan="3" class="borderline" ></TD>
      </TR>
            <TR>
              <TD width=1230 height=98><P>  <FONT
                              color=#666666>在多大程度上受理智的控制,又在多大程度上受“本能”情绪的控制?
                回答以下问题,将每题分值相加的总和与结果对照,可以确定情绪状态与类型。</FONT></P>
                    <P><FONT color=#666666>1、如果让你选择,你更愿意: <BR>
                          <INPUT
                              type=radio value=V1 name=c1>
                      同许多人一起工作并亲密接触。
                      <INPUT
                              type=radio value=V2 name=c1>
                      和一些人一起工作。
                      <INPUT
                              type=radio value=V3 name=c1>
                      独自工作。&nbsp;<BR>
                      &nbsp;&nbsp; <BR>
                      2、当为解闷而读书时,你喜欢: <BR>
                      <INPUT type=radio value=V4 name=c2>
                      读史书、秘闻、传记类。
                      <INPUT type=radio value=V5 name=c2>
                      读历史小说、“社会问题”小说。
                      <INPUT type=radio value=V6
                              name=c2>
                      读幻想小说、荒诞小说。<BR>
                      &nbsp;&nbsp;&nbsp;<BR>
                      3、对恐怖影片反映如何?<BR>
                      <INPUT
                              type=radio value=V7 name=c3>
                      不能忍受。
                      <INPUT
                              type=radio value=V8 name=c3>
                      害怕。&nbsp;
                      <INPUT
                              type=radio value=V9 name=c3>
                      很喜欢。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp; <BR>
                      4、以下哪种情况符合你:<BR>
                      <INPUT type=radio value=V10
                              name=c4>
                      很少关心他人的事。&nbsp;
                      <INPUT type=radio
                              value=V11 name=c4>
                      关心熟人的生活。&nbsp;
                      <INPUT
                              type=radio value=V12 name=c4>
                      爱听新闻,关心别人的生活细节。<BR>
                      &nbsp;&nbsp;&nbsp; <BR>
                      5、去外地时,你会:<BR>
                      <INPUT type=radio value=V13
                              name=c5>
                      为亲戚们的平安感到高兴。 &nbsp;
                      <INPUT type=radio
                              value=V14 name=c5>
                      陶醉于自然风光。&nbsp;
                      <INPUT
                              type=radio value=c name=c5>
                      希望去更多的地方。&nbsp;&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp; <BR>
                      6、你看电影时会哭或觉得要哭吗?<BR>
                      <INPUT type=radio
                              value=V16 name=c6>
                      经常。&nbsp;
                      <INPUT type=radio
                              value=V17 name=c6>
                      有时。&nbsp;
                      <INPUT type=radio
                              value=V18 name=c6>
                      从不。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;<BR>
                      7、遇见朋友时,通常是:<BR>
                      <INPUT
                              type=radio value=V19 name=c7>
                      点头问好。&nbsp;
                      <INPUT
                              type=radio value=V20 name=c7>
                      微笑、握手和问候。&nbsp;
                      <INPUT type=radio value=V21 name=c7>
                      拥抱他们。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      8、如果在车上有个烦人的陌生人要你听他讲自己的经历,你会怎样: <BR>
                      <INPUT
                              type=radio value=V22 name=c8>
                      显示你颇有同感。&nbsp;
                      <INPUT type=radio value=V23 name=c8>
                      真的很感兴趣。
                      <INPUT type=radio value=V23 name=c8>
                      打断他,做自己的事。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      9、是否想过给报纸的问题专栏写稿?<BR>
                      <INPUT type=radio
                              value=V24 name=c9>
                      绝对没想过。&nbsp;
                      <INPUT type=radio
                              value=V25 name=c9>
                      有可能想过。&nbsp;
                      <INPUT type=radio
                              value=V26 name=c9>
                      想过。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      10、被问及私人间题,你会怎样?<BR>
                      <INPUT type=radio
                              value=V27 name=c10>
                      感到不快活和气愤,拒绝回答。
                      <INPUT
                              type=radio value=V28 name=c10>
                      平静他说出你认为适当的话。&nbsp;
                      <INPUT type=radio value=V29 name=c10>
                      虽然不快,但还是回答了。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      11、在咖啡店里要了杯咖啡,这时发现邻座有一位姑娘在哭泣,你会怎样?<BR>
                      <INPUT
                              type=radio value=V30 name=c11>
                      想说些安慰话,但却羞于启口
                      <INPUT type=radio value=V31 name=c11>
                      问她是否需要帮助
                      <INPUT type=radio value=V32 name=c11>
                      换个座位远离她<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      12、在朋友家聚餐之后,朋友和其爱人激烈地吵了起来,你会怎样?<BR>
                      <INPUT
                              type=radio value=V33 name=c12>
                      觉得不快,但无能为力。&nbsp;
                      <INPUT type=radio value=V34 name=c12>
                      立即离开。&nbsp;
                      <INPUT type=radio value=V35 name=c12>
                      尽力为他们排解。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;<BR>
                      13、送礼物给朋友:<BR>
                      <INPUT
                              type=radio value=V36 name=c13>
                      仅仅在新年和生日。&nbsp;
                      <INPUT type=radio value=V37 name=c13>
                      全凭兴趣。
                      <INPUT
                              type=radio value=V37 name=c13>
                      在觉得有愧或忽视了他们时。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      14、一个刚相识的人对你说了些恭维话,你会怎样?<BR>
                      <INPUT type=radio
                              value=V38 name=c14>
                      感到窘迫。&nbsp;
                      <INPUT type=radio
                              value=V39 name=c14>
                      谨慎地观察对方。&nbsp;
                      <INPUT
                              type=radio value=V40 name=c14>
                      非常喜欢听,并开始喜欢对方。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      15、如果你因家事不快,上班时你会:<BR>
                      <INPUT type=radio
                              value=V41 name=c15>
                      继续不快,并显露出来。&nbsp;
                      <INPUT
                              type=radio value=V42 name=c15>
                      工作起来,把烦恼丢在一边。&nbsp;
                      <INPUT type=radio value=V43 name=c15>
                      尽量理智,但仍因压不住而发脾气。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      16、生活中的一个重要关系破裂了,你会:<BR>
                      <INPUT type=radio
                              value=V44 name=c16>
                      感到伤心,但尽可能正常生活。
                      <INPUT
                              type=radio value=V45 name=c16>
                      至少在短暂时间内感到痛心。&nbsp;
                      <INPUT type=radio value=V46 name=c16>
                      无可奈何地摆脱忧伤之情。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      17、一只迷路的小猫闯进你家,你会:<BR>
                      <INPUT type=radio
                              value=V47 name=c17>
                      收养并照顾它。&nbsp;
                      <INPUT
                              type=radio value=V48 name=c17>
                      扔出去。&nbsp;
                      <INPUT
                              type=radio value=V49 name=c17>
                      想给它找个主人,找不到就让它安乐死。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      &nbsp; <BR>
                      18、对于信件或纪念品,你会:<BR>
                      <INPUT type=radio
                              value=V50 name=c18>
                      刚收到时便无情地扔掉。&nbsp;
                      <INPUT
                              type=radio value=V51 name=c18>
                      保存多年。&nbsp;
                      <INPUT
                              type=radio value=V50 name=c18>
                      两年清理一次。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      19、是否因内疚或痛苦而后悔?<BR>
                      <INPUT type=radio value=V52
                              name=c19>
                      是的,一直很久。
                      <INPUT type=radio value=V53
                              name=c19>
                      偶尔后悔。&nbsp;
                      <INPUT type=radio value=V52
                              name=c19>
                      从不后悔。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
                      20、同一个很羞怯或紧张的人谈话时,你会:<BR>
                      <INPUT
                              type=radio value=V54 name=c20>
                      因此感到不安。&nbsp;
                      <INPUT type=radio value=V55 name=c20>
                      觉得逗他讲话很有趣。&nbsp;
                      <INPUT type=radio value=V56
                              name=c20>
                      有点生气。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      &nbsp; <BR>
                      21、你喜欢的孩子是:<BR>
                      <INPUT type=radio
                              value=V57 name=c21>
                      很小的时候,而且有点可怜巴巴。
                      <INPUT
                              type=radio value=V58 name=c21>
                      长大了的时候。
                      <INPUT
                              type=radio value=V59 name=c21>
                      能同你谈话的时候,并且形成了自己的个性。
                      &nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      22、爱人抱怨你花在工作上的时间太多了,你会怎样?<BR>
                      <INPUT type=radio
                              value=V60 name=c22>
                      解释说这是为了你们两人的共同利益,然后仍象以前那样去做。&nbsp;
                      <INPUT
                              type=radio value=V61 name=c22>
                      试图把时间更多地花在家庭上。&nbsp;
                      <INPUT type=radio value=V62
                              name=c22>
                      对两方面的要求感到矛盾,并试图使两方面都令人满意。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp; <BR>
                      23、在一场特别好的演出结束后,你会:<BR>
                      <INPUT type=radio
                              value=V63 name=c23>
                      用力鼓掌。&nbsp;
                      <INPUT type=radio
                              value=V64 name=c23>
                      勉强地鼓掌。
                      <INPUT type=radio
                              value=V65 name=c23>
                      加入鼓掌,但觉得很不自在。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      24 、当拿到母校出的一份刊物时,你会:<BR>
                      <INPUT type=radio
                              value=V66 name=c24>
                      通读一遍后扔掉。&nbsp;
                      <INPUT
                              type=radio value=V67 name=c24>
                      仔细阅读,并保存起来。
                      <INPUT
                              type=radio value=V68 name=c24>
                      不看就扔进垃圾桶。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      25、看到路对面有一个熟人时,你会:<BR>
                      <INPUT type=radio
                              value=V69 name=c25>
                      走开。&nbsp;
                      <INPUT type=radio
                              value=V70 name=c25>
                      走过去问好。&nbsp;
                      <INPUT type=radio
                              value=V71 name=c25>
                      招手,如对方没反应便走开。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
                      26、听说一位朋友误解了你的行为,并且正在生你的气,你会怎样?<BR>
                      <INPUT
                              type=radio value=V72 name=c26>
                      尽快联系,作出解释。&nbsp;
                      <INPUT type=radio value=V73 name=c26>
                      等朋友自己清醒过来。&nbsp;
                      <INPUT type=radio value=V74
                              name=c26>
                      等待一个好时机再联系,但对误解的事不作解释。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;<BR>
                      27、怎样处置不喜欢的礼物? <BR>
                      <INPUT type=radio value=V83 name=c27>
                      立即扔掉。
                      <INPUT type=radio value=V82 name=c27>
                      热情地保存起来。
                      <INPUT type=radio value=V83 name=c27>
                      藏起来,仅在赠者来访时才摆出来。<BR>
                      &nbsp;&nbsp;&nbsp;&nbsp;<BR>
                      28、对示威游行,爱国主义行动,宗教仪式的态度如何?<BR>
                      <INPUT
                              type=radio value=V84 name=c28>
                      冷淡。
                      <INPUT
                              type=radio value=V85 name=c28>
                      感动得流泪。
                      <INPUT
                              type=radio value=V86 name=c28>
                      使你窘迫。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp; <BR>
                      29、有没有毫无理由地觉得过害怕?<BR>
                      <INPUT type=radio
                              value=V87 name=c29>
                      经常。
                      <INPUT type=radio
                              value=V88 name=c29>
                      偶尔。&nbsp;
                      <INPUT type=radio
                              value=V89 name=c29>
                      从不。&nbsp;<BR>
                      &nbsp;&nbsp;&nbsp; <BR>
                      30、下面哪种情况与你最相符?<BR>
                      <INPUT type=radio value=V90
                              name=c30>
                      十分留心自己的感情。&nbsp;
                      <INPUT type=radio
                              value=V91 name=c30>
                      总是凭感情办事。&nbsp;
                      <INPUT
                              type=radio value=V90 name=c30>
                      感情没什么要紧,结局才最重要。</FONT> </P>
                <P align=center><SPAN
                              style="FONT-SIZE: 14px; LINE-HEIGHT: 18px"><FONT
                              color=#666666>
                  <INPUT style="FONT-SIZE: 14px; LINE-HEIGHT: 18px; FONT-FAMILY: 宋体" onclick=processForm(this.form) type=button value=提交结果 name=button><input name="answer" type="text">
                </FONT></SPAN></P>
                <DIV align=center></DIV></TD>
            </TR>
          </TBODY>
        </TABLE>
        <DIV></DIV>
      </FORM></TD>
    </TR>
    <TR>
      <TD height=1 colspan="2" background=""></TD>
      <TD width="24%" background=""></TD>
    </TR>
    <TR>
      <TD colSpan=3><FONT color=#666666>测试结果倾向:</FONT>
          <TABLE cellSpacing=1 cellPadding=8 width="100%"
                        align=center bgColor=#cccccc border=0>
            <TBODY>
              <TR bgColor=#f9fdf2>
                <TD width="14%" bgColor=#f9fdf2><DIV align=left><FONT
                              color=#666666><STRONG>30一50分</STRONG>:</FONT></DIV></TD>
                <TD width="86%"
                              bgColor=#f9fdf2>理智型情绪。很少为什么事而激动,即使生气,也表现得很有克制力。主要弱点是对他人的情绪缺少反应。爱情生活很有局限,而且可能会听到人们在背后说你“冷血动物”。目前需要松驰自己。</TD>
              </TR>
              <TR bgColor=#f9fdf2>
                <TD vAlign=top bgColor=#f9fdf2><DIV align=left><FONT
                              color=#666666><STRONG>51一69分</STRONG>:</FONT></DIV></TD>
                <TD vAlign=top
                              bgColor=#f9fdf2>平衡型情绪。时而感情用事,时而十分克制。即使在很恶劣的环境下握起了拳头,但仍能从情绪中摆脱出来。因此,很少与人争吵,爱情生活十分愉快、轻松。即使偶尔陷入情感纠纷,也能不自觉地处理得妥贴。</TD>
              </TR>
              <TR bgColor=#f9fdf2>
                <TD bgColor=#f9fdf2><DIV align=left><FONT
                              color=#666666><STRONG>70一90分</STRONG>:</FONT></DIV></TD>
                <TD
                              bgColor=#f9fdf2>冲动型情绪。是个非常重感情的人。如果是女人,一定是眼泪的俘虏。如果是男人,可能非常随和,但好强,且喜欢自我炫耀。可能经常陷入那种短暂的风暴式的爱情纠纷,因此麻烦百出,想劝你冷静,简直是不可能的事情。这里有必要提醒你:限制自己。</TD>
              </TR>
            </TBODY>
          </TABLE></TD>
    </TR>
  </TBODY>



[ 本帖最后由 boyfuture 于 2009-9-13 16:43 编辑 ]
搜索更多相关主题的帖子: 判断 
2009-09-13 15:09
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
把详细代码列出以便测试
2009-09-13 15:20
boyfuture
Rank: 1
等 级:新手上路
帖 子:552
专家分:0
注 册:2005-12-20
收藏
得分:0 
发不上去了,咋回事?
请问能不能提供这个案例:
如:
1.****
a       b    c
2.****
a        b    c
3.****
a        b     c

达到这样的目的:1.那个没有选择,提示几号题没有选择 2.全部选择后计算出总的结果 3.循环判断所有的选项

非常感谢啊!


[ 本帖最后由 boyfuture 于 2009-9-13 16:59 编辑 ]
2009-09-13 16:40
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
设置个默认值就不用判断哪个没有选择了这样就会简单化很多
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. 
<html xmlns="http://www. 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>无标题文档</title> 
<style type="text/css"> 
*{margin:0; padding:0; font-size:12px} 
form{width:700px; margin:0 auto} 
fieldset{border:1px solid #f50; padding:5px; margin-bottom:8px} 
legend{background-color:#f60; color:#fff; padding:3px 8px} 
.btn{height:22px; line-height:18px; border:1px solid #c5c6c4; padding:2px 8px} 
</style> 
<script language="javascript"> 
$ = function(obj) {return typeof obj == 'string' ? document.getElementById(obj) : obj}; 
post = function(f) { 
    var score = 0; 
 
    if(f.q1[0].checked) {score += 3};    //回答正确加三分 
    if(f.q1[1].checked) {score += -1};    //回答错误扣一分 
     
    if(f.q2[0].checked) {score += 3};    //回答正确加三分 
    if(f.q2[1].checked) {score += -1};    //回答错误扣一分 
     
    if(f.q3[0].checked) {score += 3};    //回答正确加三分 
    if(f.q3[1].checked) {score += -1};    //回答错误扣一分 
     
    if(f.q4[0].checked) {score += 3};    //回答正确加三分 
    if(f.q4[1].checked) {score += -1};    //回答错误扣一分 
 
    if(f.q5[0].checked) {score += 3};    //回答正确加三分 
    if(f.q5[1].checked) {score += -1};    //回答错误扣一分 
 
    if(f.q6[0].checked) {score += 3};    //回答正确加三分 
    if(f.q6[1].checked) {score += -1};    //回答错误扣一分 
     
    if(f.q7[0].checked) {score += 3};    //回答正确加三分 
    if(f.q7[1].checked) {score += -1};    //回答错误扣一分             
 
    if(f.q8[0].checked) {score += 3};    //回答正确加三分 
    if(f.q8[1].checked) {score += -1};    //回答错误扣一分 
 
    if(f.q9[0].checked) {score += 3};    //回答正确加三分 
    if(f.q9[1].checked) {score += -1};    //回答错误扣一分 
 
    if(f.q10[0].checked) {score += 3};    //回答正确加三分 
    if(f.q10[1].checked) {score += -1};    //回答错误扣一分     
    var arr = f.getElementsByTagName('fieldset'); 
    for(var ) 
    alert(arr.length);         
    score = score * 100 /30; 
    alert('您的份数为:'+score);         
} 
</script> 
</head> 
 
<body> 
<form> 
    <fieldset> 
           <legend>1、这是第一题吗?</legend> 
        A:<input type="radio" name="q1" value="a" checked="checked" />是 
        B:<input type="radio" name="q1" value="b" />不是 
    </fieldset> 
    <fieldset> 
           <legend>2、这是第二题吗?</legend> 
        A:<input type="radio" name="q2" value="a" checked="checked" />是 
        B:<input type="radio" name="q2" value="b" />不是 
    </fieldset> 
    <fieldset> 
           <legend>3、这是第三题吗?</legend> 
        A:<input type="radio" name="q3" value="a" checked="checked" />是 
        B:<input type="radio" name="q3" value="b" />不是 
    </fieldset> 
    <fieldset> 
           <legend>4、这是第四题吗?</legend> 
        A:<input type="radio" name="q4" value="a" checked="checked" />是 
        B:<input type="radio" name="q4" value="b" />不是 
    </fieldset> 
    <fieldset> 
           <legend>5、这是第五题吗?</legend> 
        A:<input type="radio" name="q5" value="a" checked="checked" />是 
        B:<input type="radio" name="q5" value="b" />不是 
    </fieldset>  
    <fieldset> 
           <legend>6、这是第六题吗?</legend> 
        A:<input type="radio" name="q6" value="a" checked="checked" />是 
        B:<input type="radio" name="q6" value="b" />不是 
    </fieldset>  
    <fieldset> 
           <legend>7、这是第七题吗?</legend> 
        A:<input type="radio" name="q7" value="a" checked="checked" />是 
        B:<input type="radio" name="q7" value="b" />不是 
    </fieldset>  
    <fieldset> 
           <legend>8、这是第八题吗?</legend> 
        A:<input type="radio" name="q8" value="a" checked="checked" />是 
        B:<input type="radio" name="q8" value="b" />不是 
    </fieldset>  
    <fieldset> 
           <legend>9、这是第九题吗?</legend> 
        A:<input type="radio" name="q9" value="a" checked="checked" />是 
        B:<input type="radio" name="q9" value="b" />不是 
    </fieldset>  
    <fieldset> 
           <legend>10、这是第十题吗?</legend> 
        A:<input type="radio" name="q10" value="a" checked="checked" />是 
        B:<input type="radio" name="q10" value="b" />不是 
    </fieldset>                              
    <input type="button" onclick="post(this.form)" class="btn" value="提交" />  
    <input type="reset" class="btn" value="重置" />          
</form> 
</body> 
</html> 
2009-09-14 10:05
anuo520
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2009-9-30
收藏
得分:0 
那要是有一百题的话 不是要很麻烦
2009-09-30 14:33
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
以下是引用anuo520在2009-9-30 14:33:07的发言:

那要是有一百题的话 不是要很麻烦
如果是结合ASP的服务端代码来实现就不麻烦了,有多少题都没问题。
 if(f.q1[0].checked) {score += 3};    //回答正确加三分
    if(f.q1[1].checked) {score += -1};    //回答错误扣一分
     
    if(f.q2[0].checked) {score += 3};    //回答正确加三分
    if(f.q2[1].checked) {score += -1};    //回答错误扣一分
     
    if(f.q3[0].checked) {score += 3};    //回答正确加三分
    if(f.q3[1].checked) {score += -1};    //回答错误扣一分
     
    if(f.q4[0].checked) {score += 3};    //回答正确加三分
    if(f.q4[1].checked) {score += -1};    //回答错误扣一分

    if(f.q5[0].checked) {score += 3};    //回答正确加三分
    if(f.q5[1].checked) {score += -1};    //回答错误扣一分

    if(f.q6[0].checked) {score += 3};    //回答正确加三分
    if(f.q6[1].checked) {score += -1};    //回答错误扣一分
     
    if(f.q7[0].checked) {score += 3};    //回答正确加三分
    if(f.q7[1].checked) {score += -1};    //回答错误扣一分            

    if(f.q8[0].checked) {score += 3};    //回答正确加三分
    if(f.q8[1].checked) {score += -1};    //回答错误扣一分

    if(f.q9[0].checked) {score += 3};    //回答正确加三分
    if(f.q9[1].checked) {score += -1};    //回答错误扣一分

    if(f.q10[0].checked) {score += 3};    //回答正确加三分
    if(f.q10[1].checked) {score += -1};    //回答错误扣一分     
就是把这段代码也变成循环比如
<%
   Dim i
   For i=0 To 10
       With Response
           .Write "if(f.q"&i&"[0].checked) {score += 3}; //回答正确加三分 "
           .Write "if(f.q"&i&"[1].checked) {score += -1};    //回答错误扣一分
       End With
   Next
%>
这样循环即使有再多的题一样能统计分数。
2009-09-30 15:44
快速回复:关于js的循环判断问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050399 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved