控制input框只读可以防止用户对数据的更改,在某些情况下还是比较实用的,下面使用js来完成这个只读实现
New Documentcontent="">
name="Description" content="">
function isreadonly(){
var obj =
document.getElementById("username");
obj.setAttribute("readOnly",true);
obj.style.backgroundColor="#d2d2d2";
}
function readwrite(){
var
obj = document.getElementById("username");
obj.setAttribute("readOnly",false);
obj.style.backgroundColor="#ffffff";
}
id="addform" method="post" action="" >
id="username" name="username">
value="read" οnclick="isreadonly();">
value="write" οnclick="readwrite();">