I want to disable the referenced control in the HTML and javascript below, yet it’s not doing it. Seems simple enough. What could I be missing?
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title>
<script language="javascript" type="text/javascript">
function Disable(isDisable, controlID) {
var objControl = document.getElementById(controlID);
if (objControl != null) {
objControl.disabled = isDisable;
}
}
</script>
</head>
<body>
<form name="form1" id="form1">
<input name="date?4" type="text" value="1/1/2011 12:00:00 AM" id="date?4" runat="server" style="border-color:Black;font-family:Arial;width:300px;"
/><input type="checkbox" style="font-family: Arial" onclick="Disable(this.checked, "date?4" );" >Disable
</form></body>
</html>
Your onclick is badly formatted:
Use this instead:
If you use double quotes (
") as your attribute value delimiters, you can’t use them inside the value without escaping them. You should use single quotes (') inside.