<HTML> <HEAD> <title>用JavaScript控制文件框的只读状态</title> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- //功能:翻转文件框的只读状态 function btnSetTxtBoxReadOnly_onClick(btnSetState, txtBox) { var oldState = txtBox.readOnly; txtBox.readOnly = !oldState; txtBox.value = (oldState==true ? "可写" : "只读"); btnSetState.value = (oldState==true ? "设为只读" : "设为可写"); } //--> </SCRIPT> <font color="purple" size="+2">用JavaScript控制文件框的只读状态---Purple Endurer原创</font> <FORM name="frmTest"> <INPUT TYPE="text" NAME="txtTest" value="可写" /> <INPUT TYPE="button" name="btnSetTxtBoxReadOnly" value="设为只读" onClick="btnSetTxtBoxReadOnly_onClick(this, document.frmTest.txtTest)"/> </FORM> </BODY> </HTML>