如何用javascript把页面上的所有控件变为不可用 HTML控件的disabled = true 可以把该控件设置成不可用的状态;document.getElementsByTagName("input")可以遍历页面上的所有<input>控件,之后就自己发挥吧,应该够用了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!-- DW6 --><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>shawl.qiu template</title></script><script type="text/javascript">//<![CDATA[ function test(obj){ for(var i=0; i<obj.length; i++){ for(var j=0; j<obj[i].length; j++){ obj[i][j].disabled=true; } } }//]]></script></head><body><form name="form1" id="form1" method="post" action=""> <p> <input type="text" name="textfield" /> <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"></textarea> <br /> <input type="submit" name="Submit" value="Submit" /> <input type="button" name="Button" value="Button" /> </p></form><form name="form2" id="form2" method="post" action=""> <p> <input type="text" name="textfield" /> <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"></textarea> <br /> <input type="submit" name="Submit" value="Submit" /> <input type="button" name="Button" value="Button" /> </p></form><button onclick="test(document.forms)">控件不可用</button></body></html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!-- DW6 --><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>shawl.qiu template</title></script><script type="text/javascript">//<![CDATA[ function fFmDsabComp(obj){ for(var i=0; i<obj.length; i++){ for(var j=0; j<obj[i].length; j++){ switch(obj[i][j].id){ case 'tbx': break; case 'tbx1': break; case 'txa': break; case 'txa1': break; default: obj[i][j].disabled=true; } } } }//]]></script></head><body><form name="form1" id="form1" method="post" action=""> <p> <input type="text" name="textfield" id="tbx"/> <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"></textarea> <br /> <input type="submit" name="Submit" value="Submit" /> <input type="button" name="Button" value="Button" /> </p></form><form name="form2" id="form2" method="post" action=""> <p> <input type="text" name="textfield" id="tbx1" /> <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" id="txa1"></textarea> <br /> <input type="submit" name="Submit" value="Submit" /> <input type="button" name="Button" value="Button" /> </p></form><button onclick="fFmDsabComp(document.forms)">控件不可用</button></body></html> 网上找到一段自动编号代码,但无法调节,请高手帮忙 javascript 2个循环问题。 谢谢 在高德地图上面标点问题 用js处理一段url JQuery集合JSF的问题 jQuery 操作XML 插件 求教学视频下载地址! 如何实现批量打印? 急!两个页面之间怎么用JAVASCRIPT传值? 一个小问题!help 怎么让DIV居中 自己写的java脚本为什么不能正确跳转至希望的页面。
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>shawl.qiu template</title></script>
<script type="text/javascript">
//<![CDATA[
function test(obj){
for(var i=0; i<obj.length; i++){
for(var j=0; j<obj[i].length; j++){
obj[i][j].disabled=true;
}
}
}
//]]>
</script>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<p>
<input type="text" name="textfield" />
<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"></textarea>
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="button" name="Button" value="Button" />
</p>
</form>
<form name="form2" id="form2" method="post" action="">
<p>
<input type="text" name="textfield" />
<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"></textarea>
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="button" name="Button" value="Button" />
</p>
</form><button onclick="test(document.forms)">控件不可用</button>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>shawl.qiu template</title></script>
<script type="text/javascript">
//<![CDATA[
function fFmDsabComp(obj){
for(var i=0; i<obj.length; i++){
for(var j=0; j<obj[i].length; j++){
switch(obj[i][j].id){
case 'tbx': break;
case 'tbx1': break;
case 'txa': break;
case 'txa1': break;
default: obj[i][j].disabled=true;
}
}
}
}
//]]>
</script>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<p>
<input type="text" name="textfield" id="tbx"/>
<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"></textarea>
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="button" name="Button" value="Button" />
</p>
</form>
<form name="form2" id="form2" method="post" action="">
<p>
<input type="text" name="textfield" id="tbx1" />
<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" id="txa1"></textarea>
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="button" name="Button" value="Button" />
</p>
</form>
<button onclick="fFmDsabComp(document.forms)">控件不可用</button>
</body>
</html>