Anzeige von Geburtsdatum oder Alter
Möchten Sie die Anzeige von Geburtsdatum oder Alter unterbinden?
Wählen Sie eine Darstellungsart aus
Name und Anschrift

Quelltext dieser Webseite

  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Checkbox zum de/aktivieren von anderen Elementen</title>
  5.        
  6.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7.         <meta http-equiv="expires" content="0">
  8.        
  9.         <script type="text/javascript">
  10.             /*
  11.              * Fügt Arrays eine foreach Funktion hinzu
  12.              * Wird hier nicht gebraucht, dient nur als Beispiel
  13.              */
  14.             Array.prototype.foreach = function( callback ) {
  15.                 for( var key=0; key<this.length; key++ ) {
  16.                     callback( key, this[ key ] );
  17.                 }
  18.             }
  19.  
  20.             /*
  21.              * Fügt Objekten eine foreach Funktion hinzu
  22.              */
  23.             Object.prototype.foreach = function( callback ) {
  24.                 for( var key in this ) {
  25.                     if(this.hasOwnProperty(key)) {
  26.                         callback( key, this[ key ] );
  27.                     }
  28.                 }
  29.             }
  30.  
  31.             /*
  32.              * Fügt Objekten eine ability Funktion hinzu
  33.              * enabled oder disabled (input) Objekte
  34.              */
  35.             Object.prototype.ability = function(a){
  36.                 var me = this;
  37.                 this.foreach(function(key, val){
  38.                     me[key].disabled = a;
  39.                 })
  40.             }
  41.  
  42.             /*
  43.              * Initialisierungsroutine
  44.              * Wird am Ende von body aufgerufen.
  45.              * Besser als onload(), das erst aufgerufen wird, wenn alle Bilder und andere nachladbaren Elemente der Seite geladen sind.
  46.              */
  47.             function run(){
  48.                 // Behandlungsroutine der CheckBox initialisieren - onclick()
  49.                 byid('geb').onclick = function(){
  50.                     // alle gebradio de/aktivieren
  51.                     byname('gebradio').ability(this.checked);
  52.                     // Bei Bedarf alle gebradio unchecken
  53.                     if(this.checked){
  54.                         byname('gebradio').foreach(function(key, radio){
  55.                             radio.checked = false;
  56.                         })
  57.                     }
  58.                     // Schriftfarbe für die dl mit den gebradio anpassen
  59.                     byid('auswahl').style.color = (this.checked) ? 'gray' : 'black';
  60.                 }
  61.                 // Die Funktion einmal ausführen, um den Status von geb zu prüfen (nach Reload o.ä.)
  62.                 byid('geb').onclick();
  63.             }
  64.  
  65.             /*
  66.              * Gibt eine Referenz auf das Objekt mit der ID id zurück
  67.              */
  68.             function byid(id){
  69.                 return document.getElementById(id);
  70.             }
  71.  
  72.             /*
  73.              * Gibt eine Referenz auf ein Objekt, dass alle Objekte mit dem Namen name enthält, zurück
  74.              */
  75.             function byname(name){
  76.                 return document.getElementsByName(name);
  77.             }
  78.         </script>
  79.  
  80.         <style type="text/css">
  81.             body{
  82.                 font-family: verdana, georgia, arial, sans-serif;
  83.             }
  84.             .sourcecode {
  85.                 border:1px solid #c0c0c0;
  86.                 background-color:#f8f8f8;
  87.                 margin:10px 5px;
  88.                 padding:10px;
  89.             }
  90.  
  91.             dl {
  92.                 padding:0;
  93.                 margin:0;
  94.                 margin-bottom:1em
  95.             }
  96.             dt {
  97.                 margin:0;
  98.                 padding:0;
  99.                 margin-left:120px;
  100.                 font-weight:bold;
  101.             }
  102.             dd {
  103.                 padding:0;
  104.                 margin:0;
  105.             }
  106.  
  107.             form {
  108.                 width:50%;
  109.                 margin:0 auto;
  110.                 padding:1em 1.5em;
  111.                 background:#ffe8c0;
  112.                 border:4px solid #f0a080;
  113.                 border-radius:15px;
  114.                 -webkit-border-radius:15px;
  115.                 -moz-border-radius:15px;
  116.                 -khtml-border-radius:15px;
  117.                 behavior:url('css/border-radius.htc'); /* Dem Internet Explodierer muss man erst einmal Benehmen beibringen, wenns um runde Ecken geht */
  118.             }
  119.  
  120.             form fieldset {
  121.                 margin-bottom:1em;
  122.                 background:#d8f0ff;
  123.                 border:4px solid #80a0f0;
  124.                 border-radius:15px;
  125.                 -webkit-border-radius:15px;
  126.                 -moz-border-radius:15px;
  127.                 -khtml-border-radius:15px;
  128.                 behavior:url('css/border-radius.htc'); /* Dem Internet Explodierer muss man erst einmal Benehmen beibringen, wenns um runde Ecken geht */
  129.             }
  130.             form fieldset legend {
  131.                 height:1.3em;
  132.                 font-size:1.1em;
  133.                 font-weight:bold;
  134.                 margin:1em 0 1em 1em;
  135.                 padding:0 .5em;
  136.                 background:#c0e0ff;
  137.                 border:4px solid #80a0f0;
  138.                 border-radius:15px;
  139.                 -webkit-border-radius:15px;
  140.                 -moz-border-radius:15px;
  141.                 -khtml-border-radius:15px;
  142.                 behavior:url('css/border-radius.htc'); /* Dem Internet Explodierer muss man erst einmal Benehmen beibringen, wenns um runde Ecken geht */
  143.             }
  144.  
  145.             #geb:checked+label {
  146.                 color:#f00000;
  147.             }
  148.  
  149.             label.textlabel {
  150.                 float:left;
  151.                 width:120px; /* das gleiche Maß wird auch für margin-left bei dt, input[type="radio"] und input[type="checkbox"] verwendet */
  152.                 text-align:right;
  153.                 padding-top:3px;  /* Damit es hübscher aussieht*/
  154.             }
  155.  
  156.             input[type="radio"], input[type="checkbox"] {
  157.                 margin-left:120px;
  158.             }
  159.  
  160.             input[type="text"], input[type="password"] {
  161.                 margin-bottom: 4px;
  162.             }
  163.             input[type="submit"] {
  164.                 cursor:pointer;
  165.                 font-weight:bold;
  166.                 background:#f0e8c0;
  167.                 border:4px solid #e0c880;
  168.                 border-radius:15px;
  169.                 -webkit-border-radius:15px;
  170.                 -moz-border-radius:15px;
  171.                 -khtml-border-radius:15px;
  172.                 behavior:url('css/border-radius.htc'); /* Dem Internet Explodierer muss man erst einmal Benehmen beibringen, wenns um runde Ecken geht */
  173.             }
  174.         </style>
  175.     </head>
  176.     <body>
  177.         <form id="gebdat" action="#" method="post">
  178.             <fieldset>
  179.                 <legend>Anzeige von Geburtsdatum oder Alter</legend>
  180.                 <dl>
  181.                     <dt>Möchten Sie die Anzeige von Geburtsdatum oder Alter unterbinden?</dt>
  182.                     <dd><input type="checkbox" name="geb" id="geb"><label for="geb">Alter oder Geburtsdatum nicht anzeigen</label></dd>
  183.                 </dl>
  184.                 <dl id="auswahl">
  185.                     <dt>Wählen Sie eine Darstellungsart aus</dt>
  186.                     <dd><input type="radio" name="gebradio" id="geb1" value="1"><label for="geb1">Alter</label></dd>
  187.                     <dd><input type="radio" name="gebradio" id="geb2" value="2"><label for="geb2">Tag, Monat</label></dd>
  188.                     <dd><input type="radio" name="gebradio" id="geb3" value="3"><label for="geb3">Tag, Monat, Jahr</label></dd>
  189.                 </dl>
  190.                 <dl>
  191.                     <dt>Name und Anschrift</dt>
  192.                     <dd><label class="textlabel" for="vorname">Vorname:</label><input type="text" name="vorname" id="vorname"></dd>
  193.                     <dd><label class="textlabel" for="nachname">Nachname:</label><input type="text" name="nachname" id="nachname"></dd>
  194.                 </dl>
  195.             </fieldset>
  196.             <dl>
  197.                 <dt></dt>
  198.                 <dd><input type="submit" name="gebdatsubmit" value="Absenden"></dd>
  199.             </dl>
  200.            
  201.         </form>
  202.  
  203.         <div class="sourcecode">
  204.             <h2>Quelltext dieser Webseite</h2>
  205.  
  206. <?php
  207. require_once('Ixiter_Geshi.php');
  208. echo IxiterGeshi_parseCode(file_get_contents(__FILE__));
  209. /*
  210. $src = file_get_contents(__FILE__);
  211. $lang = 'website-ish';
  212. $geshi = new Ixiter_Geshi($src, $lang);
  213. $geshi->keyword_links = false;
  214.  
  215. echo $geshi->parse_code();
  216.  *
  217.  */
  218. ?>
  219.  
  220.         </div>
  221.         <script type="text/javascript">run();</script>
  222. <?php include('./piwik.php') ?>
  223.     </body>
  224.  </html>
  225.  
(Sourcecode highlighting by Ixiters Hilighter)