<input type="text" value="" name="text1"><Script>
sub("text1");function sub(sValue){
   var value=document.getElementsByName(sValue)[0].value;
}
</Script>

解决方案 »

  1.   

    function sub(sValue){
       var value=eval("document.form1."+sValue+".value");
      }
      

  2.   


    传递input的id也可以实现<input type="text" value="" id="text1" name="text1">function sub(sValue){
       var myvalue=document.getElementById(sValue).value;
      }
      

  3.   

    谢谢 bguest(茫然的未来)  srgg(火铲))
    你们的写法都对
      

  4.   

    function sub(sValue){
       var value=document.form1(sValue).value;
      }
      

  5.   

    var value=document.form1.elements["sValue"].value;
      

  6.   

    sorry
    var value=document.form1.elements[sValue].value;
      

  7.   

    function sub(sValue){
       var value=document.all.form1.sValue.value;
      }
      

  8.   

    怎么给各位分呢?
    aniude(阿牛的乜乜)方式是错的  来访的请注意。
      

  9.   

    如果文本框在form中
    function sub(svalue){
      var value=eval("document.all.form1."+svalue+".value");
      alert(value);
    }
    否则
    function sub(svalue){
      var value=eval("document.all."+svalue+".value");
      alert(value);
    }
      

  10.   

    <form>
    <input type="text" value="" name="text1">
    </form>
    <Script>
    sub("text1");function sub(sValue){
       var value=document.getElementsByName(sValue)[0].value;
    }
    </Script>