tutorials.de Buch-Aktion 05/2012
Like Tree1Danke
  • 1 Beitrag von fpvz
ERLEDIGT
JA
ANTWORTEN
1
ZUGRIFFE
348
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Avatar von 123123123
    123123123 123123123 ist offline Mitglied Gold
    Registriert seit
    Aug 2011
    Beiträge
    177
    Hallo am so einem schönen Datum !
    Welche Variable oder Ausdruck soll ich bei switch (? ? ? ?) schreiben, damit es ausgegeben wird? Hab echt alles versucht!
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    
    <html>
        <head>
            <title>Kreis</title>
            <style>
                #box {
                    position: relative;
                    left: 600px;
                    top:  200px;
                }
                
                .punkt {
                    position: absolute;
                    width: 1px;
                    height: 1px;
                    background-color: blue;
                }
            </style>
        </head>
    <body>
        <div id="box"></div>
        
        <script>
            var oBox = document.getElementById("box");
            var oPixel = document.createElement("div");
            
            var oPixelClass = document.createAttribute("class");
            oPixelClass.nodeValue = "punkt";
            oPixel.setAttributeNode(oPixelClass);
            
            function createCircle()
            {
                var r = 200;
            
                for(var xVal=0; xVal<=r; xVal++)
                {
                    var yVal = parseInt(Math.sqrt(Math.pow(r,2) - Math.pow(xVal,2)));
                    for(q=1; q<=4; q++)
                    {
                        switch (? ? ? ?)
                        {
                            case "1":
                                x = xVal;
                                y = r-yVal;
                                
                            case "2":
                                x = xVal;
                                y = r+yVal;
                                
                            case "3":
                                x = -xVal;
                                y = r+yVal;
                        
                            case "4":
                                x = -xVal;
                                y = r-yVal;
                                            
                            var oClonePixel = oPixel.cloneNode(true);
                            var oClonePixelStyle = document.createAttribute("style");
                            oClonePixelStyle.nodeValue = "top: "+y+"px; left:"+x+"px;";
                            oClonePixel.setAttributeNode(oClonePixelStyle);
                            
                            oBox.appendChild(oClonePixel);
                        }
                    }
                }
            }
            
            createCircle();
            
        </script>
    </body>
    </html>

    Mercii!
     

  2. #2
    fpvz fpvz ist offline Mitglied Silber
    Registriert seit
    Oct 2011
    Beiträge
    74
    q



    Desweiteren fehlt dir nach jedem case ein break;
    Dazu noch der default-wert.

    Deine Variablenzuordnung muss ausserhalb der Switch-Anweisung stehen.

    Gruß
    123123123 bedankt sich.