Jump to content

Stupid Disable/Enable Problem


DarkPrince2005

Recommended Posts

Can someone please tell me where I'm going wrong? Noting seems to work....

 

<html>
<head><title></title>
<script type="text/javascript" language="javascript">
function online(){
if(document.respond.online_response.checked)
{
document.respond.response.disabled = false;
}
else{
	document.respond.response.disabled = true;
}
</script>
</head>
<body>
<form name="respond">
<input type="checkbox" name="online_response" id="online_response" onclick="online()" />
<input type="text" name="response" id="response" disabled />
</form>


</body></html>

Link to comment
https://forums.phpfreaks.com/topic/184103-stupid-disableenable-problem/
Share on other sites

You're missing the closing bracket for your online function

 

function online(){
   if(document.respond.online_response.checked)
{
   document.respond.response.disabled = false;
   }
   else{
      document.respond.response.disabled = true;
}
} /*  

 

A cleaner way of doing this would be this though.

function online() {
     document.respond.response.disabled = (document.respond.online_response.checked) ? false : true;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.