Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with code to enable/disable input with checkbox 1

Status
Not open for further replies.

upplepop

IS-IT--Management
Jun 1, 2002
173
0
0
US
For some reason, the code below is giving me an error:

Error: 'document.Update[...].checked' is null or not an object[\i]

Code:
<html>
<head>
<title>Enable / Disable</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function fncEnable(chkname)
{
if(document.Update["chk_"+chkname].checked == true)
{
 document.Update[chkname].className = 'enabledclass';
 document.Update[chkname].disabled = false;
}
else
{
 document.Update[chkname].className = 'disabledclass';
 document.Update[chkname].disabled = true;
}
}  
//-->
</SCRIPT>
<style>
  .enabledclass{background:ffffff}
  .disabledclass{background:efefef}
</style>
</head>
<body>
  <form name="Update" method="post" action="">
    <input type="checkbox" name="chk_name" value="1" OnClick="fncEnable(name)">
    <input type="text" name="name" value="" DISABLED CLASS="disabledclass">
  </form>
</body>
</html>
[\code]
 
onclick should be:

Code:
<input type="checkbox" name="chk_name" value="1" OnClick="fncEnable([red]'[/red]name[red]'[/red])">

as a general practice, avoid using reserved words (like name) as element names.



*cLFlaVA
----------------------------
[tt]( <P> <B>)[sup]13[/sup] * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks. I figured it was something simple I wasn't seeing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top