<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<script language="javascript">
function a(name){
alert(eval("document.all."+name).value);
}</script>
<body>
<input type=text name="aaa" onclick='a("bbb")'>
<input type="text" name="bbb" value="222">
</body></html>

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>
    </head>
    <script language="javascript">
    function a(name){
    var objs=document.getElementsByName(name);
    for(var i=0;i<objs.length;i++)
    alert(objs[i].value);
    }
    </script>
    <body>
    <input type=button value="test" onclick='a("bbb")'>
    <input type="text" name="bbb" value="222">
    <input type="text" name="bbb" value="222">
    </body>
    </html>