I'm completely versed in the show/hide options available, but have a problem I haven't been able to figure out. I have 5 checkbox input options, the first two options providing the same show div. For example,
As you can see, the first two options should show the same div. Selecting one or both isn't a problem, the div appears as should, but when deselecting one of the checkboxes, the div disappears even though one of the checkboxes is still selected.Code:<html> <head> <script type="text/javascript"> <!-- function showMe (it, box) { var vis = (box.checked) ? "block" : "none"; document.getElementById(it).style.display = vis; } //--> </script> </head> <body> <form> <input type="checkbox" name="modtype" value="value1" onclick="showMe('div1', this)" />value1 <input type="checkbox" name="modtype" value="value2" onclick="showMe('div1', this)" />value2 <input type="checkbox" name="modtype" value="value3" onclick="showMe('div2', this)" />value3 <input type="checkbox" name="modtype" value="value4" onclick="showMe('div3', this)" />value4 <input type="checkbox" name="modtype" value="value5" onclick="showMe('div4', this)" />value5 <div class="row" id="div1" style="display:none">Show Div 1</div> <div class="row" id="div2" style="display:none">Show Div 2</div> <div class="row" id="div3" style="display:none">Show Div 3</div> <div class="row" id="div4" style="display:none">Show Div 4</div> </form> </body> </html>
Does anyone have an idea as to how I can get the div to remain selected when one of the two checkboxes is deselected? Or, if either of the checkboxes are selected, to provide just one result?
Thanks!



Reply With Quote
please be patient This what I need I added a submit button to trigger the show/hide of only the check boxes I selected. The initial state of all boxes should be unselected, once I check the boxes I want and click on the button only those divs should show up.

thanks

Bookmarks