我使用了extremecomponents显示 合并症 项目。代码如下。<ec:table items="rows" action="${pageContext.request.contextPath}/ComplicationNew.do?operate=toCreate" title="检查项列表" 
imagePath="${pageContext.request.contextPath}/images/extremecomponents/zh_CN/*.gif" showPagination="false"
locale="zh_CN" rowsDisplayed="5" var="t" view="compact" retrieveRowsCallback="limit" filterable="false" sortable="false">
<ec:row> <ec:column property="complicationItem.complicationCat" title="类别" filterable="false" style="font-size:12px" />
<ec:column property="complicationItem.complicationName" title="合并症名称" sortable="false" filterable="false" style="font-size:12px"/>
<ec:column property="beginDate" title="开始时间" sortable="false" filterable="false"  style="font-size:12px">
<script>popdate("beginDate")</script>
<input type="text" name="beginDate" value="${beginDate}" size="10"  maxlength="10" />
</ec:column>
<ec:column property="endDate" title="终止时间" sortable="false" filterable="false"  style="font-size:12px">
<script>popdate("endDate")</script>
<input type="text" name="endDate" value="${endDate}" size="10"  maxlength="10" />
</ec:column>

<ec:column property="treatment" title="治疗方式" sortable="false" filterable="false"  style="font-size:12px">
<input type="radio" name="treatment" value = "1">住院     
<input type="radio" name="treatment" value = "2">门诊    
<input type="radio" name="treatment" value = "3">未治疗
</ec:column>
<ec:column property="outcome" title="转归" sortable="false" filterable="false"  style="font-size:12px">
<input type="radio" name="outcome" value = "0">没有变化 
<input type="radio" name="outcome" value = "1">治愈     
<input type="radio" name="outcome" value = "2">好转    
<input type="radio" name="outcome" value = "3">恶化
</ec:column>
<ec:column property="re" title="备注" sortable="false" filterable="false"  style="font-size:12px">
<input type="text" name="re" value="${re}" size="30"  maxlength="40" />
<input type="hidden" name="detail_id" value="${t.id}">
<input type="hidden" name="complication_item_id" value="${t.complicationItem.id}">
</ec:column>
</ec:row>
</ec:table>页面显示上没有任何问题。但是,点击任何一行上的radio,比如说“治疗方式”,整列radio的取值都跟着联动了。怎么样才能避免连动呢?
请大家帮帮忙。。谢谢

解决方案 »

  1.   

    我明白了楼上“分组用”是什么意思了。
    他的意思应该是对radio进行分组。
    谢谢他的提醒,虽然还是碰到问题,但至少让我觉得有了一些进展。。
    下面单独以一列说明问题:<ec:column property="outcome" title="转归" sortable="false" filterable="false"  style="font-size:12px">
                <input type="radio" name="outcome" value = "0">没有变化 
                <input type="radio" name="outcome" value = "1">治愈     
                <input type="radio" name="outcome" value = "2">好转    
                <input type="radio" name="outcome" value = "3">恶化
            </ec:column>因为前面已经声明了变量
    <% int i = 0; %>
    所以我打算这么弄:<ec:column property="outcome" title="转归" sortable="false" filterable="false"  style="font-size:12px">
              <%=++i%>
              <input type="radio" name="outcome"+<%= i%> value = "0">没有变化 
                <input type="radio" name="outcome"+<%= i%> value = "1">治愈     
                <input type="radio" name="outcome"+<%= i%> value = "2">好转    
                <input type="radio" name="outcome"+<%= i%> value = "3">恶化
            </ec:column>发现不行。通过打印对象的name,发现第一行的name为outcome+1,第二行的name为outcome+2..要是能把+号去掉就好了。
    所以,用了eval函数。如下:
    <ec:column property="outcome" title="转归" sortable="false" filterable="false"  style="font-size:12px">
              <%=++i%>
              <input type="radio" name=eval("outcome"+<%= i%>) value = "0">没有变化 
                <input type="radio" name=eval("outcome"+<%= i%>) value = "1">治愈     
                <input type="radio" name=eval("outcome"+<%= i%>) value = "2">好转    
                <input type="radio" name=eval("outcome"+<%= i%>) value = "3">恶化
            </ec:column>
    问题更大。他根本就不认识eval函数。。
    打印第一行对象的name,为 name='eval("outcome"+1) '
    晕。。
    来火了..
    于是,我干脆全部改回:
    <ec:column property="outcome" title="转归" sortable="false" filterable="false"  style="font-size:12px">
                <input type="radio" name="outcome" value = "0">没有变化 
                <input type="radio" name="outcome" value = "1">治愈     
                <input type="radio" name="outcome" value = "2">好转    
                <input type="radio" name="outcome" value = "3">恶化
            </ec:column>
    然后在<body>中修改一下:
    <body onload="initDate()">
    通过调用initDate函数,在页面载入的时候,强行给他们分组。
    initData()函数代码如下:function   initDate(){   
    alert("aaaaaaaaa");
    var outcome = document.getElementsByName("outcome");
    var l= outcome.length
    alert(l);
    for(i=0;i<l;i++){
    var  outhtml=outcome[i].outerHTML;   
           var  objname=outcome[i].name;
           var  objvalue=outcome[i].value;
           outhtml=outhtml.replace("name="+objname,"name="+objname+parseInt(i/4)); 
           outhtml=outhtml.replace("value="+objvalue,"value="+i%4); 
           outcome[i].outerHTML=outhtml; 
           alert(i+"|"+outhtml);        
    }
    alert("ffffffff");
    }   
    发现有如下几个问题:
    1 outcome.length返回40(我页面本来就40个radio,name都为outcome)。这没问题。但是循环的时候,只循环了20次,然后就提示outcome不是对象或者为空。
    2 在前面定义radio的时候,我已经制定了value。但是,我打印alert(outhtml)的时候,发现value自己改了,改得莫名其妙。所以,在上面代码中,我再次加入强行修改value的代码。
    3 最严重的!按照上面的代码,根据修改name,可以对他们进行分组(按照他们在outcome[]中的顺序,每4个为一组)但是调试时候发现,同为一组的4个radio,并不是同一行上的,并且不是连续分布,两两相隔了一个元素。晕。我倒是搞不明白通过getElementsByName函数得到的数组,里面元素的排列规则了。。问题很严重,思路很混乱。
    看我打这么多字的份上,大家帮我想想办法吧,顺便帮我分析分析上面的几个问题。。
    拜谢了~~
      

  2.   

    补充:
    问题2其实 是由问题3导致的。。
    原来,通过getElementsByName函数得到的数组的配列顺序是这样的(我页面有40个radio,4个为一行。):
    1  21  2  22
    3  23  4  24
    5  25  6  26
    7  27  8  28
    9  29  10  30
    11  31  12 32
    13  33  14  34
    15  35  16  36
    17  37  18  38
    19  39  20  40
    按照数组中的顺序依次取每个对象的value,理所当然的就得到 0,2,0,2,0,2,0,2,0,2,0,2.......1,3,1,3,1,3,1,3.....
    明白了他的排列规则,也就很容易对他们进行分组。
    但是问题1呢?
    还是弄不明白为什么只循环了20次,就提示outerHTML不是对象或者为空。
    继续努力~~