87,920
社区成员
发帖
与我相关
我的任务
分享
<!--默认为readonly你加个属性就行了-->
<input name="txt_tcreason" type=text id="txt_tcreason" readonly="readonly"/>
<!--补充1楼代码,少了ID-->
<div align="center"><input name="txt_tcreason" type=text id="txt_tcreason"></div><
<td bgcolor="#E8DBE8">
<div align="center">
<select name="txt_phonesol" onchange="javascript:document.getElementById('txt_tcreason').readOnly=(this.value==0)">
<option value="0">readonly</option>
<option value="1">text</option>
</select>
</div></td>
<td><div align="center"><input name="txt_tcreason" type=text></div></td>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<select name="txt_phonesol" id="txt_phonesol">
<option value="0">readonly</option>
<option value="1">text</option>
</select>
<input name="txt_tcreason" type='text' id="txt_tcreason"></div>
<script type="text/javascript">
function $(id) {
return typeof id === 'string' ? document.getElementById(id) : id;
}
$("txt_phonesol").onchange = function() {
var iptElem = $('txt_tcreason');
if(this.value == "1") {
iptElem.removeAttribute("readOnly");
iptElem.focus();
iptElem.style.backgroundColor = '#FFFFFF';
} else {
iptElem.setAttribute("readOnly", true);
iptElem.style.backgroundColor = '#CCCCCC';
}
}
$("txt_phonesol").onchange();
</script>
</body>
</html>