function ClearAll()
{
var ipts = document.getElementsByTagName("INPUT");
for( var i = 0; i < ipts.length; i++ )
{
if( ipts[i].type == "text" )
{
ipts[i].value = "";
}
}
}
{
var ipts = document.getElementsByTagName("INPUT");
for( var i = 0; i < ipts.length; i++ )
{
if( ipts[i].type == "text" )
{
ipts[i].value = "";
}
}
}
<script type="text/javascript">
//<![CDATA[
function fClrFormVal(o){
if(!o) return false;
for(var i=0; i<o.length; i++){
if(o[i].type==='text'||o[i].type==='textarea')o[i].value='';
}
return false;
} // shawl.qiu script
//]]>
</script>
<form name="form1" id="t" method="post" action="">
<input name="textfield" type="text" value="tttttttttttttttttttt" />
<br />
<input type="checkbox" name="checkbox" value="checkbox" />
<input type="checkbox" name="checkbox" value="checkbox" />
<input type="checkbox" name="checkbox" value="checkbox" />
<br />
<input name="radiobutton" type="radio" value="radiobutton" />
<input name="radiobutton" type="radio" value="radiobutton" />
<input name="radiobutton" type="radio" value="radiobutton" />
<br />
<textarea name="textarea">ddddddddddddddddddddd</textarea>
</form><br />
<a href="#" onclick="fClrFormVal(document.getElementById('t'));">置空</a>
{
var ipts = document.getElementsByTagName("INPUT");
for( var i = 0; i < ipts.length; i++ )
{
if( ipts[i].type == "text" )
{
ipts[i].value = "";
}
}
}同意。
function ClearAllInput()
{
for(var i=0;i<document.all.length;i++)
{
if(document.all[i].type == "text" || document.all[i].type == "textarea")
{
document.all[i].value = "";
}
}
}
{
var ipts = document.getElementsByTagName("INPUT");
for( var i = 0; i < ipts.length; i++ )
{
if( ipts[i].type == "text" || ipts[i].type == "hidden" || ipts[i].type == "password" )
{
ipts[i].value = "";
}
if( ipts[i].type == "checkbox" || ipts[i].type == "radio" )
{
ipts[i].checked = false;
}
if( ipts[i].type == "file" )
{
ipts[i].outerHTML = ipts[i].outerHTML;
}
} var tas = document.getElementsByTagName("TEXTAREA");
for( var i = 0; i < tas.length; i++ )
{
tas[i].value = "";
} var sts = document.getElementsByTagName("SELECT");
for( var i = 0; i < sts.length; i++ )
{
sts[i].selectedIndex = -1;
}
}
不行,这个只是重设,达不到楼主的要求Amwpfiqvy(给我分吧,让我升仙)
的方法可以实现