日期:2014-05-16  浏览次数:20350 次

js控制readonly问题
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
</head>
<script language="JavaScript">
function isreadonly(){
var obj = document.getElementById("username");
obj.setAttribute("readOnly",true);
}
function readwrite(){
var obj = document.getElementById("username");
obj.setAttribute("readOnly",false);
}
</script>
<body>
  <form name="addform" id="addform" method="post" action="">
  <input type="text" id="username" name="username" >
  <input type="button" name="只读" value="只读" onclick="isreadonly();">
  <input type="button" name="可写" value="可写" onclick="readwrite();">
  </form>
</body>
</html>