怎么默认选中第一个啊,我用的document.all("selected")[0].checked="checked";这句话在eclipse中是可以的,但是到了IE8里面有不行了,快整死我了
单选按钮是这样生成的,求大侠指点本人新手:
<%
while(rs.next()){
%>
<tr class="tbl_detail0">
<td rowspan="1" class="td_center">
<input value = "<%=rs.getString(1) %>" type="radio" name="selected" id="selected" / >
</td>
<td class="td_left"><%=rs.getString(1) %></td>
</tr>
<%
if(rs.next()){
%>
<tr class="tbl_detail1">
<td rowspan="1" class="td_center">
<input value = "<%=rs.getString(1) %>" type="radio" name="selected" id="selected" />
</td>
<td class="td_left"><%=rs.getString(1)%></td>
</tr>
<%
}
}
%>
有个人让我从
document.all("selected")[0].checked=true;该过来的,也是不行啊
你定义一个变量比如:i;
" type="radio" name="selected" id="selected" / >
在循环的时候i++;
这样就可以是radio的id = selected1,id = selected2等等了,因为id必须是唯一的。
然后在jsp中你直接找到这个id就可以了:
document.getElementById("select1").checked = true;