I wrote a small piece of javascript a while ago to add some text to a text box and mark it as read only if a check box was checked. If the checkbox was unchecked, the text would be removed and the field writable.

It was working great until I accadently deleted the file and had to start over from an old backup that didn't have the new functionality.. Now I have it so if you check the box, it puts the correct text, and marks the field read only, hoverer now I can't uncheck the checkbox.

Here is what I have this far:


<script type="text/javascript">
	function disabler()
		if (document.forms[0].micro.checked = true){
			document.forms[0].status.value='...some text...';
			document.forms[0].status.readOnly = true;
		} else if (document.forms[0].micro.checked = false){
			document.forms[0].status.readOnly = false;


shipping/tracking number:<input type='text' name='status' id='status'> (<input type='checkbox' name='micro' id='micro' onchange='disabler()'> : Micro Note)

thanks for any help!

1. It probably isn't a good idea to use the word 'status' as a field name. It is a reserved word
2. your comparison needs to have a double equal rather than a single - if(foo==bar)
3. you don't need an else if, you just need else


<input type=text name="microstatus" id="microstatus" value="...bla..."><input type=checkbox name=micro id=micro value=1 onclick="disabler(this);">


function disabler(obj){

That did it!

Thanks for the help!