Chodzi mi o uniwersalny skrypt bez koneiczności nadawania ID każdemu DL i FIELDSET.
Klikamy w fieldset i dl znika. Klikamy ponownie i DL pojawia się.
<form action="" method="post" id="formularz"> <fieldset> <dl> </dl> </fieldset> <fieldset> <dl> </dl> </fieldset> </form> <script type="text/javascript"> function aktywacja_ukrywania_formularza ( id ) { this.id = id; var tagi_fieldset = document.getElementById(id).getElementsByTagName('fieldset'); for (var n = 0; n < tagi_fieldset.length; ++n) { var tagi_dl = tagi_fieldset[n].getElementsByTagName('dl'); var tag_legend = tagi_fieldset[n].getElementsByTagName('legend'); tag_legend[0].onclick = function () { for (var m = 0; m < tagi_dl.length; ++m) { if ( tagi_dl[m].style.display == 'none' ) { tagi_dl[m].style.display = ''; } else { tagi_dl[m].style.display = 'none'; } } }; } } aktywacja_ukrywania_formularza ( 'formularz' ); </script>
<script type="text/javascript"> $(document).ready(function() { $('fieldset').click(function () { $(this).children('dl').hide(); return true; }); $('fieldset').dblclick(function () { $(this).children('dl').show(); return true; }); }); </script> <form action="" method="get"> <fieldset> <dl> </dl> </fieldset> <fieldset> <dl> </dl> </fieldset> </form>
<?php <script type="text/javascript"> $(document).ready(function() { $('fieldset').children('legend').click(function () { if ( $(this).parent().children('dl').css("display") == 'none' ) { $(this).parent().children('dl').show(); } else { $(this).parent().children('dl').hide(); } return true; }); }); </script> ?>