# Solved: onclick not working properly in IE7 / Opera



## jaymanson (Mar 18, 2007)

Hi all, been a while! 

The following code works exactly as it should in Firefox - you should only be able to enter text into the field if the checkbox is ticked. However, in IE7 and Opera, the field is disabled regardless of the state of the checkbox.


```
<form action="test.php" method="post">
<input name="box" type="checkbox" onclick="document.getElementById('name').disabled=!this.checked}">
<input name="name" type="text" id="name" disabled="true" size="40">
</form>
```
Can anybody suggest a fix or an alternative method to achieve the desired result in all browsers?

Thanks in advance :up:

Jay


----------



## MMJ (Oct 15, 2006)

Hey jay. 

You have an unopened curly brace "}" at the end of the code. Removing that should fix it.


----------



## jaymanson (Mar 18, 2007)

Oh bugger! 

I was doing this at the end of a long day of learning / coding PHP and I think I'd fried my brain by that point. At least all my PHP code worked just fine 

Cheers MMJ 

PS Sorry I never got back to your PM from months ago! I've not actually logged in for that long, and I don't remember getting an email from the forum to tell me I had a PM??


----------



## MMJ (Oct 15, 2006)

Yeah, the emails are sometimes a bit unstable. Its ok. 

Good luck with PHP.


----------

