html - How do I disable TextBox using JavaScript? -


earlier asked disabling button when drop down menu item selected. given code did trick need same textbox , odd reason not working can have me...

html:

<form id="frmcolor">     <input type='textbox' id='color' />     <input type='submit' value='change color' id="colorsubmit"/>  </form> 

javascript:

  tools.eraser = function () {     var tool = this;     this.started = false;     var varpencolor = "white";     context.strokestyle = varpencolor;     document.getelementbyid('frmcolor').colorsubmit.disabled=true;     document.getelementbyid('frmcolor').color.disabled=true; 

any ideas why wont disable text box?

thanks

form elements can accessed via form's dom element name, not "id" value. give form elements names if want access them that, or else access them directly "id" value:

document.getelementbyid("color").disabled = true; 

edit — oh also, pointed out others, it's "text", not "textbox", "type" attribute.

you might want invest little time in reading front-end development tutorials.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -