Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][JavaScript]Ukrycie domyślnie diva...
Forum PHP.pl > Forum > Przedszkole
Alessio
Jak zrobić, by div był widoczny tylko ten co w polu input jest zaznaczony, bo pokazuje mi tego drugiego też, natomiast gdy zaznacze któryś z divów ręcznie to działa, pokazuje tylko ten jeden, jak to zrobić?
  1.  
  2. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  3. <script language="javascript" type="text/javascript" src="script.js"></script>
  4. <title>divy, ukrywane</title>
  5. <style type="text/css">
  6. body {font-family:verdana;font-size:14pt;color:#FF0000;}
  7. </head>
  8.  
  9. Pokaż diva:<br />
  10.  
  11. <input type="radio" checked="checked" value="1" id="url1" onClick="return uploadfile('url1');" />1 div<br />
  12. <input type="radio" value="2" id="url2" onClick="return uploadfile('url2');" />2 div
  13.  
  14.  
  15. <br /><br />
  16. <div id="test1">
  17.  
  18. Zawartość diva 1
  19.  
  20. </div>
  21. <div id="test2">
  22.  
  23. druga zawartosc diva
  24.  
  25. </div>
  26. </body>
  27.  
  28. </html>


  1. function uploadfile(id)
  2. {
  3. if(document.getElementById(id).value==1)
  4. {
  5. document.getElementById("test2").style.display="none";
  6. document.getElementById("test1").style.display="block";
  7. return true;
  8. }
  9. if(document.getElementById(id).value==2)
  10. {
  11. document.getElementById("test1").style.display="none";
  12. document.getElementById("test2").style.display="block";
  13. return true;
  14. }
  15. }
barthpl
  1. <div id="test2" style="display: none">
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.