<HTML>
<HEAD>
<script language="javascript">
function change()
{
if(totaldu.value.length>=10)
{
totaldu.size=totaldu.value.length+1;
totaldu.maxLength=totaldu.value.length+1;
}
}
</script></head>
<body>
<input name="totaldu" type="text" id="totaldu" size="10" maxlength="10" onkeyup="change()">
</body>
</html>
<HEAD>
<script language="javascript">
function change()
{
if(totaldu.value.length>=10)
{
totaldu.size=totaldu.value.length+1;
totaldu.maxLength=totaldu.value.length+1;
}
}
</script></head>
<body>
<input name="totaldu" type="text" id="totaldu" size="10" maxlength="10" onkeyup="change()">
</body>
</html>
function increase(){
document.all.totaldu.size=document.all.totaldu.value.length
}
</Script>
<input name="totaldu" type="text" id="totaldu" size="10" maxlength="10" onchange="increase()">同理,要设置最小长度的话增加一个判断就可以了。
对于刷新页面又回到原来的状况这是无法避免的,除非用script写页面,
这样才能保持改变的长度。并且,刷新页面之后是肯定没有了用户输入
的值了的,这个时候,你的要求就没有意义了。当然,你用script写页面的
话,就可以保持值。
{
document.cookie = sName + "=" + escape(sValue) + "; ";
}
function GetCookie(sName)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
}
input {behavior:url(#default#savehistory);}
</style>
<input name="totaldu" type="text" id="totaldu" size="10" style="overflow:visible">