<input style="width:20;overflow:visible">

解决方案 »

  1.   

    两种方式,一种是css就是上面老大说的input style="width:20;overflow:auto">
    另一种在脚本中:
    document.form1.name.style.overflow=auto可以查一下msdn
      

  2.   

    谢谢上面两位! 我会再查查资料的。
    因为不但要自动适应字符长度,还要得到当前的长度。用上面两种方法我没有试过的。
    比如接上面的,用
    var inputElement = document.getElementById("test");
    var width = inputElement.width;
    现在还不确定,会不会返回“”?
      

  3.   

    上面的两位老大,我设置了css就是上面老大说的input style="width:20;overflow:auto">
    结果却不可以
      

  4.   

    这是那个input的初始信息:
    <textarea onKeyDown="javascript:finishedEdit(event,this)" onChange="javascript:onChangeVal()" name="floatcfgDscpField" id="floatcfgDscpField" style=" visibility: hidden; position: absolute; left: -500; top: -500" cols="40" rows="4"></textarea>
    在脚本中:
    var foloatElement=document.getElementById("floatcfgDscpField");
    foloatElement.style.overflow="visible";
    结果是textarea中输入字符到开始默认的宽度后就自动换行.而不会延长