checkbox 实现单选
<script type="text/javascript">
//校验必须要打分
function checkqualitygrade(){
var flag =true;
var _gradesnodes = $("input[id ^= 'hiddenqgitem_']");
//先清空
$.each(_gradesnodes, function(_i, _el){
_el.value ='';
});
//再赋值
var gradesnodes = $("input[id ^= 'qgitem_']");
$.each(gradesnodes, function(i, el){
var obj = ('hidden'+);
if(){
$(obj).stk_val();
}
});
//校验
$.each(_gradesnodes, function(_i, _el){
if( _el.value ==null || _el.value =='')
flag =false;
});
return flag;
}
function clickCheckBox(element){
var elementName = $(element).attr("name");
var obj = (elementName);
for (i=0; i<; i++){
if (obj[i]!=element ){
obj[i].checked = false;
}
else obj[i].checked = ;
// else obj[i].checked = true;
}
}
</script>
<div style="margin-top:10px;margin-bottom: 10px">
<table width='800px' class='stk-table stk-table-bbline'>
<tr>
<th colspan="3" class='stk-table-th' style='text-align: left'>Quality Grade</th>
</tr>
<tr>
<td class="stk-table-td alignC"></td>
<td class="stk-table-td alignC" style="font-weight: bold;"> Grade Item</td>
<td class="stk-table-td alignC" style="font-weight: bold;"> Score Value</td>
</tr>
<c:forEach items="${qualitygradeitems}" var="items" varStatus="i">
<tr>
<td class="stk-table-td alignC">${+1}</td>
<td class="stk-table-td alignL"> ${}</td>
<td class="stk-table-td alignC">
<c:set var="key" value="G_${empid}_${}" scope="page"/>
<c:forEach items="${qualitygradevalues}" var="values" >
<label>${}
<input name="qgitem_${empid}_${}_value" id="qgitem_${empid}_${}_value"
type="checkbox" value="${}" onclick="clickCheckBox(this)"
${( eq grademap[key]) ? 'checked' : ''} /></label>
</c:forEach>
<input type="hidden" name="hiddenqgitem_${empid}_${}_value" id="hiddenqgitem_${empid}_${}_value" />
</td>
</tr>
</c:forEach>
</table>
</div>