Ankündigung

Einklappen
Keine Ankündigung bisher.

Einem Button eine Funktion hinzufügen

Einklappen

Neue Werbung 2019

Einklappen
Dieses Thema ist geschlossen.
X
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Einem Button eine Funktion hinzufügen

    Hallo,
    Ich habe einen Kalender erstellt und ich habe jetzt zwei Button hinzufügen die den Monat verändern sollen.
    Das heißt mit dem einem Button zrück und mit dem anderen vor.
    Verwendet habe ich <button>❮</button> und <button>❯</button> diese beiden Button sollen die
    Funktion haben.

    Wie kann ich den Monat verändern?

    Diese Monats-Variable habe ich für den Kalender benutzt:
    <?php
    $month = 1;
    $monate = array(
    1=>"Januar",
    2=>"Februar",
    3=>"März",
    4=>"April",
    5=>"Mai",
    6=>"Juni",
    7=>"Juli",
    8=>"August",
    9=>"September",
    10=>"Oktober",
    11=>"November",
    12=>"Dezember"
    );
    echo $monate[$month];
    ?>[/PHP]

  • #2
    und will jetzt zwei Button hinzufügen
    ok, mach nur.

    Und was ist deine Frage? Oder wo steckst du konkret? Du brauchst übrigens den März nicht verstümmeln.

    Und bitte PHP-Code-Tags verwenden.
    The string "()()" is not palindrom but the String "())(" is.

    Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
    PHP.de Wissenssammlung | Kein Support per PN

    Kommentar


    • #3
      Tut mir leid formulierungsfehler.
      Ich meinte:"Ich habe einen Kalender erstellt und ich habe jetzt zwei Button hinzufügen die den Monat verändern sollen."

      Kommentar


      • #4
        Zitat von Bitecreation Beitrag anzeigen
        Ich meinte:"Ich habe einen Kalender erstellt und ich habe jetzt zwei Button hinzufügen die den Monat verändern sollen."
        Abgesehen davon, das der Satz auch nicht besser ist.. Mir ist schon klar was du vorhast. Worum es mir geht ist: Wo hängst du? Wo kommst du nicht weiter? Konkret! Also: Zeig deinen bisherigen Code und sag wo du steckst. Das wollen wir wissen.
        The string "()()" is not palindrom but the String "())(" is.

        Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
        PHP.de Wissenssammlung | Kein Support per PN

        Kommentar


        • #5
          Ich möchte Wissen wie Ich mit Hilfe von Buttons den angezeigten Monat verändern kann.
          Das es dann statt Januar Februar anzeigt.
          ❮(zurück) (Monat) (weiter)❯
          Die Pfeile sind die Button.

          Mein Kalender:


          PHP-Code:
          <html>
          <body>
          <title>Kalender</title>
          <center>
          <?php
          $year 
          2016;
          #echo $year;
          ?>
          <button>❮</button>

          <?
          $month = 3;
          #echo $month;
          $monate = array(
          1=>"Januar",
          2=>"Februar",
          3=>"März",
          4=>"April",
          5=>"Mai",
          6=>"Juni",
          7=>"Juli",
          8=>"August",
          9=>"September",
          10=>"Oktober",
          11=>"November",
          12=>"Dezember"
          );
          echo $monate[$month];
          ?>
          <button>❯</button>
          <?
          #array für die Feiertage
          $ostersonntag = date('Y-n-d',easter_date($year));
          $ostermontag = date('Y-n-d',easter_date($year)+60*60*24*1);
          $karfreitag = date('Y-n-d',easter_date($year)-60*60*24*2);
          $himmelfahrt = date('Y-n-d',easter_date($year)+60*60*24*39);
          $pfingsten = date('Y-n-d',easter_date($year)+60*60*24*49);
          $pfingstmontag = date('Y-n-d',easter_date($year)+60*60*24*50);
          $fronleichnam = date('Y-n-d',easter_date($year)+60*60*24*60);
          $arr_feiertage[$year.'-1-1'] = 'Neujahr';
          $arr_feiertage[$year.'-12-25'] = '1. Weihnachtstag';
          $arr_feiertage[$year.'-12-26'] = '2. Weihnachtstag';
          $arr_feiertage[$year.'-10-3'] = 'Tag der Deutschen Einheit';
          $arr_feiertage[$year.'-5-1'] = 'Maifeiertag';
          $arr_feiertage[$karfreitag] = 'Karfreitag';
          $arr_feiertage[$ostersonntag] = 'Ostersonntag';
          $arr_feiertage[$ostermontag] = 'Ostermontag';
          $arr_feiertage[$himmelfahrt] = 'Christi Himmelfahrt';
          $arr_feiertage[$pfingsten] = 'Pfingstsonntag';
          $arr_feiertage[$pfingstmontag] = 'Pfingstmontag';
          $arr_feiertage[$fronleichnam] = 'Fronleichnam';

          $firstday = date('N', mktime(0, 0, 0, $month, 1, $year));
          #echo $firstday;
          $monthdays = date('t', mktime(0, 0, 0, $month, 1, $year));
          #echo $monthdays;
          $fields = array_fill(0, 42, "");
          $start = $firstday -1;
          $end = $firstday + $monthdays -1;

          $day = 1;
          for ($i = $start; $i < $end; $i++){
          $fields[$i] = $day;
          $day ++;
          }
          ?>
          <table border="1";>
          <tr>
          <th>Mo</th>
          <th>Di</th>
          <th>Mi</th>
          <th>Do</th>
          <th>Fr</th>
          <th>Sa</th>
          <th>So</th>
          </tr>
          <tr>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[0]])) {echo "bgcolor=#FA5858"; }?>><? /*gibt ein bestimmtes Feld aus*/echo $fields[0]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[1]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[1]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[2]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[2]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[3]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[3]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[4]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[4]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[5]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[6]; ?></td>
          </tr>
          <tr>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[7]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[7]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[8]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[8]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[9]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[9]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[10]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[10]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[11]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[11]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[12]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[13]; ?></td>
          </tr>
          <tr>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[14]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[14]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[15]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[15]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[16]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[16]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[17]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[17]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[18]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[18]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[19]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[20]; ?></td>
          </tr>
          <tr>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[21]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[21]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[22]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[22]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[23]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[23]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[24]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[24]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[25]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[25]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[26]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[27]; ?></td>
          </tr>
          <tr>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[28]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[28]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[29]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[29]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[30]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[30]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[31]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[31]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[32]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[32]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[33]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[34]; ?></td>
          </tr>
          <tr>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[35]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[35]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[36]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[36]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[37]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[37]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[38]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[38]; ?></td>
          <td <? if(isset($arr_feiertage[$year."-".$month."-".$fields[39]])) {echo "bgcolor=#FA5858"; }?>><? echo $fields[39]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[40]; ?></td>
          <td bgcolor=#FA5858><? echo $fields[41]; ?></td>
          </tr>
          </table>
          </center>
          </body>
          </html>

          Kommentar


          • #6
            STOPP! Das wird so nichts, wirklich.

            Schau dir vorher grundlegende Themen an:

            HTML

            - zB Inline Attribute (font, bgcolor, ..) sind schon lange veraltet .. man nutzt CSS heutzutage

            PHP:

            - EVA Prinzip http://php-de.github.io/jumpto/eva-prinzip/

            - DRY Prinzip -> google

            - DateTime zB: http://php-de.github.io/jumpto/datetime/

            etc...

            Und nutze endlich PHP-Tags
            The string "()()" is not palindrom but the String "())(" is.

            Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
            PHP.de Wissenssammlung | Kein Support per PN

            Kommentar


            • #7
              Vielleicht bin ich ja ein Nullchecker aber du bist auch nicht besser

              Kommentar


              • #8
                Hä? Sowas hab ich nie behauptet. Was ist los mit dir?



                The string "()()" is not palindrom but the String "())(" is.

                Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
                PHP.de Wissenssammlung | Kein Support per PN

                Kommentar


                • #9
                  Zitat von hausl Beitrag anzeigen
                  Hä? Sowas hab ich nie behauptet. Was ist los mit dir?


                  Ich aber!

                  Kommentar


                  • #10
                    edit:
                    Ursprünglichen Text gelöscht.

                    Vote for ban !

                    Kommentar


                    • #11
                      Zitat von Bitecreation Beitrag anzeigen
                      Ich aber!
                      Das hat dann wohl keinen Sinn.. Schade um die Zeit, dir konstruktive Antworten / Themenvorschläge zu geben, um deinen Code zu verbessern.


                      [MOD: Geschlossen]
                      The string "()()" is not palindrom but the String "())(" is.

                      Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
                      PHP.de Wissenssammlung | Kein Support per PN

                      Kommentar

                      Lädt...
                      X