I'm setting the value for SecretAttribute dynamically via another script, but at the moment I'm having difficulties making the Name input field as readonly
.
Tried setting the getElementByID
by SecretAttribute and SecretElement, but no dice..
<input name="SecretAttribute" id="SecretAttribute" value="Y" type="checkbox" checked/>
<html>
<head>
<title>Demo Title</title>
<script type="text/javascript">
var SecretElement = document.getElementById('SecretAttribute');\
if (document.getElementById("SecretAttribute").checked;) {
function DataCheck() {
document.getElementById('Name').readOnly = true;
}
}
</script>
</head>
<body onload="DataCheck()">
Demo6.1<br>
Name: <input type="text" id="Name" name="Name"><br>
</body>
</html>