发表于: 2005.09.13 21:36
分类: Javascript/HTML
出处: http://sigui.itpub.net/post/5428/40885
---------------------------------------------------------------
如果我们需要用javascript控制/设置表单的readonly属性,如果使用document.myform.mytext.readony=true/false 是没有任何作用的,如果控制的话,可以将mytext加一个ID然后用ID控制readonly 属性,代码如下
<html>
<script>
function ee()
{
document.getElementById("MyID").readOnly=true;//-->正确
// document.myform.ff.readonly=false; ---->错误
}
</script>
<body>
<form name="myform">
<input id="MyID" type="text" name="mytext" value="">
<input type="button" value="mybutton" onclick="ee()">
</form>
</body>
</html>
----------------------
下面有回复指出了,我注明错误的那一行是因为大小写的原因无效的,低级错误,抱歉!











