<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>文本框的只读和可写切换</title>
</head>
<body>
<input type="text" id="aa">
<input type="text" id="bb">
<button onclick="javascript:a();" value="writer"></button>
<button onclick="javascript:b();" value="readonly"></button>
<script type="text/javascript">
function a(){
//document.getElementById("aa").removeAttribute("readOnly");
var x=document.getElementsByTagName("input");
for(var i=0;i<x.length;i++){
x[i].removeAttribute("readOnly");
}
}
function b(){
//document.getElementById("aa").setAttribute("readOnly","true");
var x=document.getElementsByTagName("input");
for(var i=0;i<x.length;i++){
x[i].setAttribute("readOnly","true");
}
}
</script>
</body>
</html>
<html>
<head>
<title>文本框的只读和可写切换</title>
</head>
<body>
<input type="text" id="aa">
<input type="text" id="bb">
<button onclick="javascript:a();" value="writer"></button>
<button onclick="javascript:b();" value="readonly"></button>
<script type="text/javascript">
function a(){
//document.getElementById("aa").removeAttribute("readOnly");
var x=document.getElementsByTagName("input");
for(var i=0;i<x.length;i++){
x[i].removeAttribute("readOnly");
}
}
function b(){
//document.getElementById("aa").setAttribute("readOnly","true");
var x=document.getElementsByTagName("input");
for(var i=0;i<x.length;i++){
x[i].setAttribute("readOnly","true");
}
}
</script>
</body>
</html>