Apparaitre 2 tablaeu en js

tahaniabdou Messages postés 56 Statut Membre -  
Alain_42 Messages postés 5413 Statut Membre -
Bonjour,je voudrai faire apparaitre avec java script en utilisant 2 boutton radio 2 tableau chacun d'eux fait apparaitre un tableau différent sa dépend quelle radio je coche. si quelqu'un a un script a me proposé.

merci d'avance.

@+
Configuration: Windows XP Internet Explorer 6.0

1 réponse

  1. Alain_42 Messages postés 5413 Statut Membre 904
     
    voilà un chti bout de code exemple:

    <html>
    <head>
    <script type="text/javascript">
    function affich(id_bt_choix,id_aff,id_masquer){
    	var obj_bt=document.getElementById(id_bt_choix);
    	var obj_aff= document.getElementById(id_aff);
    	var obj_masquer= document.getElementById(id_masquer);
    	if(obj_bt.checked == true){
    		if(obj_aff.style.visibility=="hidden") obj_aff.style.visibility="visible";
    		if(obj_masquer.style.visibility=="visible") obj_masquer.style.visibility="hidden";
    	}
    }
    </script>
    </head>
    <body>
    <form name="test" method="post" action="">
    <input type="radio" name="bt_choix" id="bt_choix_1" value="choix_1" onChange="affich('bt_choix_1','table1','table2');">Affiche table 1<br />
    <input type="radio" name="bt_choix" id="bt_choix_2" value="choix_1" onChange="affich('bt_choix_2','table2','table1');">Affiche table 2<br /><br /><br />
    <table id="table1" style="visibility:hidden;">
    <tr><td>Je suis table 1</td></tr>
    </table>
    <table id="table2" style="visibility:hidden;">
    <tr><td>Je suis table 2</td></tr>
    </table>
    </body>
    
    </html>
    
    0