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
TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|