|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
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
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
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
Sources en rapport avec celle ci
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
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|