html - Disable a field after selection -
in piece of code need disable department field when approved selected in status(above field) , should active when clarifications selected must enabled. please try helping !
<form name="index" action="director"> <table border="0" style="width:300px"> <tbody bgcolor> <p> date: <%= df.format(new java.util.date()) %> </p> <tr> <td height="40"><font color="blue">branch:</td> <td> <select name="dbranch" id="dbranch" > <option value="select">select</option> <option value="kakinada">kakinada</option> <option value="vishakapatnam">vishakapatnam</option> <option value="tirupathi">tirupathi</option> <option value="vijayawada">vijayawada</option> <option value="warangal">warangal</option> <option value="hyderabad">hyderabad</option> </select> </td> </tr> <tr> <td height="40"><font color="blue">doc id :</td> <td> <select id="inw_id" name="inw_id"> <option value='0'>select doc id</option> </select> </td> </tr> <tr> <td height="40"><font color="blue">status: </td> <td> <select name="status" id="status" > <option value="">status</option> <option value="approved">approved</option> <option value="clarifications">clarifications</option> </select> </td> </tr> <tr> <td height="40"><font color="blue">department: </td> <td> <select name="dept" id="dept" > <option value=""> </option> <option value="admin">admin</option> <option value="accounts">accounts</option> <option value="other">other</option> </select> </td> </tr> </tbody> </table> <tr><td><td align="right"><input name="submit" type="submit" value="submit"style="background-color:lightblue;margin-left:15px;height: 40px;width: 100px; margin-right: -30px;"></td></td></tr> </form>
we tried writing function, did not work :(
function doenable() { if(document.getelementbyid("status")!="null") { document.getelementbyid("department").disabled=false; } }
if want plain javascript solution try following.
<html> <head> <script type='text/javascript'> function change(thestatus) { if (thestatus.value == "approved") { document.getelementbyid("dept").disabled = true; } else { document.getelementbyid("dept").disabled = false; } } </script> </head> <body> <select name="status" id="status" onchange="change(this)"> <option value="">status</option> <option value="approved">approved</option> <option value="clarifications">clarifications</option> </select> <select name="dept" id="dept"> <option value=""></option> <option value="admin">admin</option> <option value="accounts">accounts</option> <option value="other">other</option> </select> </body> </html>
Comments
Post a Comment