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)">
  • 相关阅读:
    机器学习(Machine Learning)&深入学习(Deep Learning)资料
    漫谈 机器学习
    Android 屏幕滑动事件
    Andriod中绘(画)图----Canvas的使用详解
    android studio上代码编译调试中遇到的一些异常记录
    Android签名详解(debug和release)
    如何用AndroidStudio导入github项目
    java synchronized详解
    视频编解码学习之一:理论基础
    Android 环境下编译FFmpeg
  • 原文地址:https://www.cnblogs.com/xinxindiandeng/p/1349961.html
Copyright © 2011-2022 走看看