javascript - If Checkbox is checked, remove attribute? -


<div class="span1">      <input type="checkbox" value="l4" id="l4" field="" defaultvalue="" appeditor="true"/> </div>  <div class="span7">      <input type="text" class="m-wrap span10" id="fld_l4" defaultvalue="" edittype="intedit" appeditor="true" disabled /> </div> 

what want is, if checkbox checked, remove disabled in fld_l4.

how using prototype.js or jquery?

edit: i'm using prototype jquery i'm getting error: uncaught invalidstateerror: attempt made use object not, or no longer, usable. way replaced $ jquery conflicts

edit2 : solved.

this.l4     = editor.instance; editor.observe(iconstants.key_change,this.levelcheckboxchanged.bindaseventlistener(this)) 

inside levelcheckboxchanged:

levelcheckboxchanged: function(e) {      if($("l4").checked == false) {         $("fld_l4").disabled = true;     } else {         $("fld_l4").disabled = false;     } }, 

here way prototypejs

inside of dom loaded event

document.observe('dom:loaded',function(){      $('l4').observe('click',function(){         $('fld_l4').writeattribute('disabled',this.checked);     });  }); 

plus might want change id of '14' browsers not starting id's numbers - let not part of html spec


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -