`
jackroomage
  • 浏览: 1200003 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类

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"> 赋值。目的是传到要访问的页面。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics