tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
2
ZUGRIFFE
280
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Jörg Infinity Jörg Infinity ist offline Grünschnabel
    Registriert seit
    Sep 2011
    Beiträge
    2
    Hi

    Ich such mich dumm und dämlich in google finde aber nicht das passende. Ich habe ein Javascript flip counter http://netcash.x10.mx/counter/index.html und möchte gerne via php code
    PHP-Code:
    <?=$rows[totalmember];?>
    die member anzahl mit dem flip counter anzeigen lassen.

    Ich weiß das man Javascript und PHP sich verbinden lässt aber nur wie.

    -- hier der quellcode vom flip counter ---------

    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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    
    <script type="text/javascript">
    //<![CDATA[
     
    // Array to hold each digit's starting background-position Y value
    var initialPos = [0, -618, -1236, -1854, -2472, -3090, -3708, -4326, -4944, -5562];
    // Amination frames
    var animationFrames = 5;
    // Frame shift
    var frameShift = 103;
     
    // Starting number
    var theNumber = 8999998596;
    // Increment
    var increment = 17;
    // Pace of counting in milliseconds
    var pace = 180;
     
    // Initializing variables
    var digitsOld = [], digitsNew = [], subStart, subEnd, x, y;
     
    // Function that controls counting
    function doCount(){
        var x = theNumber.toString();
        theNumber += increment;
        var y = theNumber.toString();
        digitCheck(x,y);
    }
     
    // This checks the old count value vs. new value, to determine how many digits
    // have changed and need to be animated.
    function digitCheck(x,y){
        var digitsOld = splitToArray(x),
        digitsNew = splitToArray(y);
        for (var i = 0, c = digitsNew.length; i < c; i++){
            if (digitsNew[i] != digitsOld[i]){
                animateDigit(i, digitsOld[i], digitsNew[i]);
            }
        }
    }
     
    // Animation function
    function animateDigit(n, oldDigit, newDigit){
        // I want three different animations speeds based on the digit,
        // because the pace and increment is so high. If it was counting
        // slower, just one speed would do.
        // 1: Changes so fast is just like a blur
        // 2: You can see complete animation, barely
        // 3: Nice and slow
        var speed;
        switch (n){
            case 0:
                speed = pace/8;
                break;
            case 1:
                speed = pace/4;
                break;
            default:
                speed = pace/2;
                break;
        }
        // Cap on slowest animation can go
        speed = (speed > 100) ? 100 : speed;
        // Get the initial Y value of background position to begin animation
        var pos = initialPos[oldDigit];
        // Each animation is 5 frames long, and 103px down the background image.
        // We delay each frame according to the speed we determined above.
        for (var k = 0; k < animationFrames; k++){
            pos = pos - frameShift;
            if (k == (animationFrames - 1)){
                $("#d" + n).delay(speed).animate({'background-position': '0 ' + pos + 'px'}, 0, function(){
                    // At end of animation, shift position to new digit.
                    $("#d" + n).css({'background-position': '0 ' + initialPos[newDigit] + 'px'}, 0);
                });
            }
            else{
                $("#d" + n).delay(speed).animate({'background-position': '0 ' + pos + 'px'}, 0);
            }
        }
    }
     
    // Splits each value into an array of digits
    function splitToArray(input){
        var digits = new Array();
        for (var i = 0, c = input.length; i < c; i++){
            subStart = input.length - (i + 1);
            subEnd = input.length - i;
            digits[i] = input.substring(subStart, subEnd);
        }
        return digits;
    }
     
    // Sets the correct digits on load
    function initialDigitCheck(initial){
        var digits = splitToArray(initial.toString());
        for (var i = 0, c = digits.length; i < c; i++){
            $("#d" + i).css({'background-position': '0 ' + initialPos[digits[i]] + 'px'});
        }
    }
     
    // Start it up
    initialDigitCheck(theNumber);
    setInterval(doCount, pace);
     
    //]]>
    </script>
     

  2. #2
    Jörg Infinity Jörg Infinity ist offline Grünschnabel
    Registriert seit
    Sep 2011
    Beiträge
    2
    schade hat niemand einen ratschlag****?
     

  3. #3
    Avatar von sheel
    sheel sheel ist gerade online Moderator
    tutorials.de Moderator
    Registriert seit
    Jul 2007
    Beiträge
    4.504
    Hi

    so ganz hab ich nicht verstanden, was du vorhast.

    Wo soll den die Zahl im HTML/JS hinkommen?
    Aus welcher Datenbankabfrage etc bekommst du die?
     
    Netiquette (vA §15) und Nutzungsregeln (vA §4.8) einhalten! Programmcode in Codetags/Codeboxen.
    Sehr gute Beiträge bitte Bewerten (Stern darunter oder "Danke").
    "Funktioniert nicht" ist zu ungenau! Code, Fehlermeldungen, Verhalten des Programms, ...?

Ähnliche Themen

  1. PHP Constante im JavaScript-Code ausgeben
    Von fredolin im Forum Javascript & Ajax
    Antworten: 9
    Letzter Beitrag: 25.02.10, 17:06
  2. Antworten: 3
    Letzter Beitrag: 09.10.08, 23:18
  3. Anzahl der Eingaben ausgeben
    Von Gwenn im Forum C/C++
    Antworten: 3
    Letzter Beitrag: 07.09.08, 00:57
  4. Anzahl aus 2 Tabellen ausgeben
    Von Deejoy im Forum Relationale Datenbanksysteme
    Antworten: 2
    Letzter Beitrag: 15.11.04, 10:44
  5. Anzahl der Einträge ausgeben
    Von Blandorin im Forum Relationale Datenbanksysteme
    Antworten: 2
    Letzter Beitrag: 22.02.04, 00:13

Stichworte