eval("window.document.form."+aaa+".value")

解决方案 »

  1.   


    window.document.form.elements['bbb'].value
      

  2.   

    <script>
    function check(A)
    {var str=eval('document.all.'+ A +'.value');
    alert(str);
    }</script><input type=text id=aaa ><input type=text id=bbb >
    <button onclick="check('aaa');">测试</button><button onclick="check('bbb');">测试</button>
      

  3.   


    o1 = document.getElementById('id');
    alert(o1);
    也行啊。