日期:2014-05-16  浏览次数:20361 次

js 控制select 和 radio 赋值和并传值

js 控制select 和 radio 并赋值和传值

下面是select用法时:
???????????? <select id="selectId" name="leibname" onchange="ckc(this.options[this.options.selectedIndex].value);">
??? ???? <option id="lei1" style="width:150px" onclick="xuanzlb();">选择审核类别</option>
??? ???? <% Iterator ite=hzFaqLeiBieList.iterator();
??? ??????????? while(ite.hasNext()){
??? ??????????? ??? HzFaqLeiBie? sname=(HzFaqLeiBie)ite.next();
??? ??????????? ??? %>
??? ??????????? ??? <option id="lei2" value="<%=sname.getMajorID() %>"><%=sname.getShortName() %></option>
??? ??????????? ??? <%
??? ??????????? }
??? ???? %>
??? ???? </select>




下面是type是radio的用法时。
<INPUT?? id=rd?? name=rd?? type=radio?? value=1?? checked>
<INPUT?? id=rd?? name=rd?? type=radio?? value=2>
<INPUT?? id=rd?? name=rd?? type=radio?? value=3>
<input?? type= "button "?? value= "click?? me "?? onClick= "test() ">
<script>
function?? test(){
//alert(document.all.rd.length);
var?? i?? =?? 0;
for(i?? =?? 0;?? i?? <?? document.all.rd.length;?? i++){
if?? (document.all.rd[i].checked?? ==?? true){
alert(document.all.rd[i].value);
}
}
}
</script>


总结:主要是拿到想拿的值再给<input type="hidden"> 赋值。目的是传到要访问的页面。