Hi guys this is my first post, just want to ask how to make a form page that hide/unhide form fields using a single checkbox. thanks!
<input type="checkbox" onclick="showfield(this.checked, 'id-of-field');" /> <input type="text" id="id-of-field" style="display: none;" /> HTML: function showfield(checked, id) { document.getElementById(id).style.display = checked ? 'block' : 'none'; } Code (javascript):
Use document.getElementsByTagName('<tag>') Code (markup): You should use a loop (foreach, for or while) to change every item's display style.
function findimg() { var imgs,i; imgs=document.getElementsByTagName('img'); for(i=0;i<imgs.length;i++) { alert(imgs[i].id); } } Code (markup): This code reads every <img> tag (image) and alerts it's id. You should use something similar. Adapt something a similar script to your needs.