html - Javascript: Disable button on Drop Down Select -
i have dropdown menu couple of values link functions. have textbox , submit button. want if value in drop down box selected disables or hides submit button , possibly textbox made blank , once value selected turns both on.
my html code:
<body> <p><label>drawing tool: <select id="dtool"> <option value="line">line</option> <option value="rect">rectangle</option> <option value="pencil">pencil</option> <option value="eraser">eraser</option> </select></label></p> //some canvas code
<form id="frmcolor"> <input type='color' id='color' /> </form> <input type='submit' value='change color' id="colorsubmit"/> javascript in linked file called canvas.js:
... tools.eraser = function () { var tool = this; this.started = false; var varpencolor = "white"; context.strokestyle = varpencolor; document.frmcolor.colorsubmit.disabled=true; basically when select eraser drop down works submit button not disable.
im new js , not sure if need add sort of listener or element id ideas?
you have submit button outside of form. (as seen in example code..)
<form id="frmcolor"> <input type='color' id='color' /> </form> <input type='submit' value='change color' id="colorsubmit"/> should be
<form id="frmcolor"> <input type='color' id='color' /> <input type='submit' value='change color' id="colorsubmit"/> </form>
Comments
Post a Comment