(1) jsp 页面中的radio部分:
?????
<div class="left">
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 软件类型:
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? </div>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <div class="right">
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <div class="radio_b">
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <input name="softType" type="radio" value="fun" />
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 娱乐
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? </div>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <div class="radio_b">
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <input name="softType" type="radio" value="game" />
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 游戏
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? </div>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <div class="radio_b">
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <input name="softType" type="radio" value="chat" />
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 聊天
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? </div>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <div class="radio_b">
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <input name="softType" type="radio" value="other" />
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 其他
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? </div>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? </div>
(2) 动态选择的JS
//<%=softInfo.getSoftType%> 为传递多来的参数
??? function getRadioValue(){
??????
var obj=document.getElementsByName("softType")
????
for(var i=0;i<obj.length;i++){
??????? if(obj[i].value==<%=softInfo.getSoftType%>){
??????????? obj[i].checked=true;
??????????? break;
}
}
}
?
(3) 页面加载的时候自动执行js
在body 属性中添加:onload="getRadioValue()"
如:<body onload="getRadioValue()">
?
?
? .....
??? </body>
?