Macchiato Posted September 7, 2012 Share Posted September 7, 2012 I'd like to disable certain input boxes, but without changing the HTML code manually. For example:I'd like to disable the input boxes with the following id's:id="first_field"id="fourth_field"id="sixth_field" <div> <form action=""> <fieldset> <input type="text" id="first_field"/> <input type="text" id="second_field"/> <input type="text" id="third_field"/> <input type="text" id="fourth_field"/> <input type="text" id="fifth_field"/> <input type="text" id="sixth_field"/> </fieldset> </form> </div> Anyone know a Javascript that can do this? Link to comment Share on other sites More sharing options...
niche Posted September 7, 2012 Share Posted September 7, 2012 removeChild http://www.w3schools.com/jsref/met_node_removechild.asp Link to comment Share on other sites More sharing options...
thescientist Posted September 7, 2012 Share Posted September 7, 2012 is there any reason you can't take anything you've been taught herehttp://w3schools.invisionzone.com/index.php?showtopic=44954 to at least make an attempt on your own first? Link to comment Share on other sites More sharing options...
Macchiato Posted September 10, 2012 Author Share Posted September 10, 2012 Woah! Take it easy man... eat a pie I always try before I post. Already found a solution: <script type="text/javascript"> var els = ["first_field", "fourth_field", "sixth_field"] for (var i = 0; i < els.length; i++) document.getElementById(els[i]).disabled = true; </script> Link to comment Share on other sites More sharing options...
thescientist Posted September 10, 2012 Share Posted September 10, 2012 how would we know what you've tried unless you posted it? Link to comment Share on other sites More sharing options...
niche Posted September 10, 2012 Share Posted September 10, 2012 (edited) thescientist does have a point. It's important that original posters demonstrate more diligence than they frequently do and not be surprised when a responder indicates that the OP should/might know better, might be dallying, or both. Edited September 10, 2012 by niche Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now