js设立input的readonly不成功

js设置input的readonly不成功本帖最后由 xtm_rongbing 于 2013-04-25 00:03:19 编辑function p_edit(id) {

js设置input的readonly不成功
本帖最后由 xtm_rongbing 于 2013-04-25 00:03:19 编辑 function p_edit(id) {
if(document.getElementById("plot_name").readOnly)
{
document.getElementById("plot_name").readOnly = false;
if(!document.getElementById("plot_name").readOnly)
alert("readonly");  
}
else
{
document.getElementById("plot_name").readOnly = true;
if(document.getElementById("plot_name").readOnly)
alert("false");
}
}


<input type="text"  id="plot_name"  name="plot_name1"  value="test" readonly />

js中的alert都可以执行,感觉是设置成功了,可是在界面中,却没有效果,请问这是为什么?求帮助,万分感谢!



[解决办法]
是readonly,注意大小写。
[解决办法]
function p_edit(id) {
if(document.getElementById("plot_name").readOnly)
{
// 你这段红色代码把readonly属性设置为了false了,即不是只读,就可编辑了
document.getElementById("plot_name").readOnly = false;
if(!document.getElementById("plot_name").readOnly)
alert("readonly");  
}
else

document.getElementById("plot_name").readOnly = true;
if(document.getElementById("plot_name").readOnly)
alert("false");
}
}