zoukankan      html  css  js  c++  java
  • 同名radio的取值

    http://www.ideagrace.com/html/doc/2005/08/04/00328.html

    <input type=radio value="1" selected name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="???">

    如何取sex的value?

    ---------------------------------------------------------------

    <script>
    function aa()
    {
    l=document.getElementsByName("sex")
    for(i=0;i<l.length;i++)
    {
    if(l[i].checked) alert(l[i].value)
    }
    }
    </script>
    <input type=radio value="1" selected name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="aa()">


    ---------------------------------------------------------------

    <input name=r type=radio value=1>
    <input name=r type=radio value=2>
    <input name=r type=radio value=3>
    <input type=submit onclick="for(i=0;i<r.length;i++)alert(r[i].value)">

    ---------------------------------------------------------------

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(var i=0;i<sex.length;i++){if(sex[i].checked)alert('your select:'+sex[i].value)}">
    ---------------------------------------------------------------

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(i=0;i<sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" value=sumit></body>

    ---------------------------------------------------------------

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(i=0;i<sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" value=sumit>

    ---------------------------------------------------------------

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(i=0;i<sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" value=submit>

    ---------------------------------------------------------------

    <input type=radio value="1" selected name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="javascript:alert(sex.value)">
  • 相关阅读:
    03-Spring默认标签解析
    想要写出好味道的代码,你需要养成这些好习惯!
    IDEA 缺少Springboot启动图标 如何添加
    echarts的canvas大小
    JS控制div上下滚动内容
    2020新的一年开始了
    2019年第一个工作日!
    关于.net项目前后端分离框架(一)
    MongoDB学习一:安装及简单使用
    spring默认标签与自定义标签学习
  • 原文地址:https://www.cnblogs.com/xinxindiandeng/p/1349961.html
Copyright © 2011-2022 走看看