This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

享受一种生活

首页 | 资源中心 | 管理控制台

« | »

用javascript控制readonly属性

ilovelate | 13 九月, 2005 23:35

如果我们需要用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>


发表评论

标题

在此添加评论

称呼

邮箱地址(可选)

个人主页(可选)




Valid XHTML 1.0 Strict and CSS.
Powered by pLog
Design by Book of Styles