IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Création d'une calculette


Sujet :

Langage PHP

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2011
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Création d'une calculette
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <?php  
     
     
        if (isset($_GET['btn']))
        {
          switch ($_GET['btn']) {
          case 1:
          $myText1 = myAction($_GET['btn']);
          break;
     
          case 2:
          $myText1 =  "dwa";
          break;
          default:
          $myText1 = "inna wartosc";
     
          }
     
        }
     
        else {
          $myText1 =0;
     
        }
     
     
        function myAction($myValue){
     
        return  $myValue;
        }
     
     
     
        ?>  
     
        <center>
        <div style="position: absolute; width: 500px; margin-left: 50%; left: -250px;">
        <form action="Kalkulator.php" method="get">
     
    			Kalkulator  </br> </br></br>
     
     
    			<input type="text" name="Text1" value="<?php echo $myText1; ?>" style=" width: 210px; float: left; margin-left: 140px;" /> 	
          </br> </br>
    			<button type="submit" name="btn" value="C" style="width: 210px;"> C </button>
          </br>                                                                                            
    			<button type="submit" name="btn" value="1" style="width:50px;" > 1 </button>
    			<button type="submit" name="btn" value="2" style="width:50px;" style="margin-left:10px"; > 2 </button>
    			<button type="submit" name="btn" value="3" style="width:50px;" style="margin-left:10px"; > 3 </button>
    			<button type="submit" name="btn" value="dodawanie" style="width:50px;" style="margin-left:10px"; > + </button>
    			</br>
    			<button type="submit" name="btn" value="4" style="width:50px;" style="margin:10px 0px 0px 10px;"; > 4 </button>
    			<button type="submit" name="btn" value="5" style="width:50px;" style="margin-left:10px"; > 5 </button>
    			<button type="submit" name="btn" value="6" style="width:50px;" style="margin-left:10px"; > 6 </button>
    			<button type="submit" name="btn" value="odejmowanie" style="width:50px;" style="margin-left:10px"; > - </button>
    			</br>
    			<button type="submit" name="btn" value="7" style="width:50px;" style="margin-left:10px"; > 7 </button>
    			<button type="submit" name="btn" value="8" style="width:50px;" style="margin-left:10px"; > 8 </button>
    			<button type="submit" name="btn" value="9" style="width:50px;" style="margin-left:10px"; > 9 </button>
    			<button type="submit" name="btn" value="mnozenie" style="width:50px;" style="margin-left:10px"; > * </button>
    			</br>
    			<button type="submit" name="btn" value="przecinek" style="width:50px;" style="margin-left:10px"; > , </button>
    			<button type="submit" name="btn" value="0" style="width:50px;" style="margin-left:10px"; > 0 </button>
    			<button type="submit" name="btn" value="rowna" style="width:50px;" style="margin-left:10px"; > = </button>
    			<button type="submit" name="btn" value="dzielenie" style="width:50px;" style="margin-left:10px"; > / </button>    
    		</form>
        </div>
        </center>
    Donc voila sa c'est un debout que j'ai fait,

    Premierement je voudrais savoir pour que: quand je click sur "C" il y a le zero qui s'apparé.
    Puis en clickant chaque numero, les nombre ce suive et forme "123456" ect

    Merci de votre aide

  2. #2
    Membre averti Avatar de beejeridou
    Homme Profil pro
    Webmaster
    Inscrit en
    Février 2007
    Messages
    280
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Février 2007
    Messages : 280
    Points : 342
    Points
    342
    Par défaut
    Je pense que tu devrais te tourner vers le javascript car la tu va faire un rechargement de page à chaque appuis sur un bouton!!!

  3. #3
    Membre habitué Avatar de omar24
    Homme Profil pro
    Inscrit en
    Septembre 2010
    Messages
    159
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2010
    Messages : 159
    Points : 172
    Points
    172
    Par défaut
    salut;

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    if (isset($_GET['btn']))
        {
         $myText1 .= myAction($_GET['btn']);
    }
    et pour afficher 0 quand un clic est fait sur C tout simplement


Discussions similaires

  1. Réponses: 14
    Dernier message: 09/04/2004, 13h44
  2. [amc designer] création d'une base postgresql
    Par david42 dans le forum PostgreSQL
    Réponses: 9
    Dernier message: 12/03/2004, 11h08
  3. Création d'une base avec IbConsole
    Par Lucien dans le forum Outils
    Réponses: 3
    Dernier message: 02/03/2004, 18h34
  4. création d'une batabse .gdb
    Par jejestyle dans le forum Bases de données
    Réponses: 3
    Dernier message: 23/02/2004, 00h29
  5. [BES] Création d'une variable d'environnement
    Par NGI80 dans le forum Autres
    Réponses: 2
    Dernier message: 17/10/2002, 07h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo