Accueil > > > CALCULATRICE SIMPLE
CALCULATRICE SIMPLE
Information sur la source
Description
Je sais qu'il y a déja des srcipts pour la calculatrice mais celle-ci est plus simple et on peut l'ouvrir dans une pop-up (pour que le visiteur ait toujours la calculatrice sous la main). Vous devez créer deux pages, une pour la calculatrice (page 1) et l'autre pour ouvrir cet page dans une pop-up (page 2).
Source
- // PAGE 1 !
-
- <html>
- <head>
- <title>Calculatrice Simple</title>
-
- <script language="JavaScript">
-
- function verification(entree) {
- var car ="1234567890[]()+-.*,/";
- for (var i = 0; i < entree.length; i++)
- if (car.indexOf(entree.charAt(i))<0 ) return false;
- return true;
- }
-
- function calcul() {
- var a = 0;
- if (verification(window.document.calculatrice.result.value))
- a = eval(window.document.calculatrice.result.value);
- window.document.calculatrice.result.value = a;
- }
-
- function ajouter(caracteres) {
- window.document.calculatrice.result.value =
- window.document.calculatrice.result.value + caracteres;
- }
-
- function fonction_speciale(fonction) {
- if (verification(window.document.calculatrice.result.value)) {
- if(fonction == "sqrt") {
- var a = 0;
- a = eval(window.document.calculatrice.result.value);
- window.document.calculatrice.result.value = Math.sqrt(a);
- }
- if(fonction == "pow") {
- var a = 0;
- a = eval(window.document.calculatrice.result.value);
- window.document.calculatrice.result.value = a * a;
- }
- if(fonction == "log") {
- var a = 0;
- a = eval(window.document.calculatrice.result.value);
- window.document.calculatrice.result.value = Math.log(a);
- }
- } else window.document.calculatrice.result.value = 0
- }
-
- </script>
- </head>
- <body>
- <table border bgcolor=#0001cc>
- <th>
- <form name="calculatrice">
- <center>
- <textarea style="WIDTH: 186px; HEIGHT: 24px; TEXT-ALIGN:right;" name="result" align="right" class="affiche"></textarea><br>
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b2" value="7" onClick="ajouter('7')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b3" value="8" onClick="ajouter('8')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b4" value="9" onClick="ajouter('9')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b12" value=":" onClick="ajouter('/')" size="30"><br>
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b5" value="4" onClick="ajouter('4')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b6" value="5" onClick="ajouter('5')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b7" value="6" onClick="ajouter('6')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b11" value="x" onClick="ajouter('*')" size="30"><br>
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b8" value="1" onClick="ajouter('1')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b9" value="2" onClick="ajouter('2')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b10" value="3" onClick="ajouter('3')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b13" value="-" onClick="ajouter('-')" size="30"><br>
- <input style="FONT-WEIGHT: bold; WIDTH: 92px; HEIGHT: 24px" type="button" name="b14" value="0" onClick="ajouter('0')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b15" value="." onClick="ajouter('.')" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b16" value="+" onClick="ajouter('+')" size="30"><br>
- <input style="FONT-WEIGHT: bold; WIDTH: 140px; HEIGHT: 24px" type="reset" name="b17" value="ON/C" size="30">
- <input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b18" value="=" onClick="calcul()" size="30"><br>
- <input style="FONT-WEIGHT: bold; WIDTH: 60px; HEIGHT: 24px" type="button" class="button" value="sqrt " onClick="fonction_speciale('sqrt')">
- <input style="FONT-WEIGHT: bold; WIDTH: 60px; HEIGHT: 24px" type="button" class="button" value=" pow " onClick="fonction_speciale('pow')">
- <input style="FONT-WEIGHT: bold; WIDTH: 60px; HEIGHT: 24px" type="button" class="button" value=" log " onClick="fonction_speciale('log')">
- </center>
- </form>
- </th>
- </table>
-
-
- </body>
- </html>
-
-
- // PAGE 2 !
-
- <html>
-
- <head>
- <title>Calculatrice Simple</title>
- </head>
-
- <body vlink="#0000FF">
-
- <p><a href="calcul.htm" target="popup"
- onmouseover="this.style.color='red'"
- onmouseout="this.style.color='blue'"
- onclick="window.open('','popup','width=218,height=215,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,status=no')">Calculatrice</a>
- </p>
- </body>
- </html>
// PAGE 1 !
<html>
<head>
<title>Calculatrice Simple</title>
<script language="JavaScript">
function verification(entree) {
var car ="1234567890[]()+-.*,/";
for (var i = 0; i < entree.length; i++)
if (car.indexOf(entree.charAt(i))<0 ) return false;
return true;
}
function calcul() {
var a = 0;
if (verification(window.document.calculatrice.result.value))
a = eval(window.document.calculatrice.result.value);
window.document.calculatrice.result.value = a;
}
function ajouter(caracteres) {
window.document.calculatrice.result.value =
window.document.calculatrice.result.value + caracteres;
}
function fonction_speciale(fonction) {
if (verification(window.document.calculatrice.result.value)) {
if(fonction == "sqrt") {
var a = 0;
a = eval(window.document.calculatrice.result.value);
window.document.calculatrice.result.value = Math.sqrt(a);
}
if(fonction == "pow") {
var a = 0;
a = eval(window.document.calculatrice.result.value);
window.document.calculatrice.result.value = a * a;
}
if(fonction == "log") {
var a = 0;
a = eval(window.document.calculatrice.result.value);
window.document.calculatrice.result.value = Math.log(a);
}
} else window.document.calculatrice.result.value = 0
}
</script>
</head>
<body>
<table border bgcolor=#0001cc>
<th>
<form name="calculatrice">
<center>
<textarea style="WIDTH: 186px; HEIGHT: 24px; TEXT-ALIGN:right;" name="result" align="right" class="affiche"></textarea><br>
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b2" value="7" onClick="ajouter('7')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b3" value="8" onClick="ajouter('8')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b4" value="9" onClick="ajouter('9')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b12" value=":" onClick="ajouter('/')" size="30"><br>
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b5" value="4" onClick="ajouter('4')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b6" value="5" onClick="ajouter('5')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b7" value="6" onClick="ajouter('6')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b11" value="x" onClick="ajouter('*')" size="30"><br>
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b8" value="1" onClick="ajouter('1')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b9" value="2" onClick="ajouter('2')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b10" value="3" onClick="ajouter('3')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b13" value="-" onClick="ajouter('-')" size="30"><br>
<input style="FONT-WEIGHT: bold; WIDTH: 92px; HEIGHT: 24px" type="button" name="b14" value="0" onClick="ajouter('0')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b15" value="." onClick="ajouter('.')" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b16" value="+" onClick="ajouter('+')" size="30"><br>
<input style="FONT-WEIGHT: bold; WIDTH: 140px; HEIGHT: 24px" type="reset" name="b17" value="ON/C" size="30">
<input style="FONT-WEIGHT: bold; WIDTH: 44px; HEIGHT: 24px" type="button" name="b18" value="=" onClick="calcul()" size="30"><br>
<input style="FONT-WEIGHT: bold; WIDTH: 60px; HEIGHT: 24px" type="button" class="button" value="sqrt " onClick="fonction_speciale('sqrt')">
<input style="FONT-WEIGHT: bold; WIDTH: 60px; HEIGHT: 24px" type="button" class="button" value=" pow " onClick="fonction_speciale('pow')">
<input style="FONT-WEIGHT: bold; WIDTH: 60px; HEIGHT: 24px" type="button" class="button" value=" log " onClick="fonction_speciale('log')">
</center>
</form>
</th>
</table>
</body>
</html>
// PAGE 2 !
<html>
<head>
<title>Calculatrice Simple</title>
</head>
<body vlink="#0000FF">
<p><a href="calcul.htm" target="popup"
onmouseover="this.style.color='red'"
onmouseout="this.style.color='blue'"
onclick="window.open('','popup','width=218,height=215,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,status=no')">Calculatrice</a>
</p>
</body>
</html>
Conclusion
Voilà, et puis regardez le fichier zip si vous ne comprennez pas ou si ça ne marche pas
Historique
- 25 juin 2006 12:34:38 :
- Je me suis aperçu que la fonction diviser ("/") ne marchait pas ! J'ai donc corriger le problème.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Rafraichir la fenetre "parent" [ par aurélien ]
Bonjour à tous, J'ai une page en html/php a partir de laquelle, en cliquant sur un bouton, j'ouvre un popup, et j'aimerais que lorsque je ferme ce pop
Fermeture de formulaire [ par Freddy ]
Dans une popup,un formulaire d'ajout je voudrais qu'une fois les données envoyer,la popup se ferme automatiquementdes idées ?
onUnload event, popup... [ par VicoLaChips2 ]
Voila mon problème. J'ai mis dans la balise bodyd'une frame le code suivant : <body onUnload="return goodbye('<% =user %>';">Le script : f
Submit et popup [ par Woby ]
Bonjour,je me demandais si il était possible d'ouvrir une autre page par l'intermédiaire d'un bouton submit sans que la page où il se trouve ne chang
Fermer PopUp [ par SYL20 ]
Bonjour, je ne m'y retrouve pas... pourriez-vous m'aider en m'indiquant une formule magique permettant de fermer une fenêtre popup lorsqu'on clique su
pb base de donnees - popup [ par ratch ]
Bonsoir à tous,J'ai un souciJ'ai une base de données qui affiche une liste de contactsavec la possiblité de cliquer sur le nom de la personne pouravoi
Fonction qui permet de fermer une popup après le chargement de cette popup [ par Nabel ]
Bonjour, bonjour,Voilà, j'ai fait un script ASP qui permet de créer un ficheir xls sur le serveur, or, je ne veux pas que ce ficheir reste sur le serv
pb d'ouverture fermeture de popup [ par jeffb ]
bonjour,j'ai ouvert une fenetre popup avec la fonction:popupHandle=open('popup.asp', 'Cobrowsing1', 'status=no, resizable=1, scrollbars=1, toolbar=0,
reload et popup [ par booth ]
bonjour voilà la situationj'ai un frame qu'on va appeler "haut", et une frame qu'on va appeler "bas".à partir de la frame "haut" je lancer un pop-up e
Distance popup [ par Braco ]
J'ai une popup placée sur l'écran. Ce que je veux, c'est récupérer la distance ( top et left ) de cette même fenêtre une fois qu'elle à été déplacée s
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|