Bonjour à tous, dans un formulaire j'utilise le script suivant pour afficher une calculette:
<head>
<script language= "javascript">
functiontape
(
valeur
)
{
old
=
document
.
calculatrice
.
ecran
.
value
;
document
.
calculatrice
.
ecran
.
value
= old
+
valeur
;
}
functionegal
()
{
varaffichage
=
document
.
calculatrice
.
ecran
.
value
;
document
.
calculatrice
.
ecran
.
value
= eval
(
affichage
);
}
functionmultiplie
()
{
old
=
document
.
calculatrice
.
ecran
.
value
;
document
.
calculatrice
.
ecran
.
value
= old
+ '*'
;
}
functioncarre
()
{
document
.
calculatrice
.
ecran
.
value
=
document
.
calculatrice
.
ecran
.
value
*
document
.
calculatrice
.
ecran
.
value
;
}
functioninverse
()
{
old
= document
.
calculatrice
.
ecran
.
value
;
document
.
calculatrice
.
ecran
.
value
=
1/
old
;
}
functionclavier
()
{
if(
event
.
keyCode
= =
96)
{
document
.
calculatrice
.
c0
.
focus
();
tape
(0);
}
if(
event
.
keyCode
==
97)
{
document
.
calculatrice
.
c1
.
focus
();
tape
(1);
}
if(
event
.
keyCode
==
98)
{
document
.
calculatrice
.
c2
.
focus
();
tape
(2);
}
if(
event
.
keyCode
==
99)
{
document
.
calculatrice
.
c3
.
focus
();
tape
(3);
}
if(
event
.
keyCode
==
100)
{
document
.
calculatrice
.
c4
.
focus
();
tape
(4);
}
if(
event
.
keyCode
==
101)
{
document
.
calculatrice
.
c5
.
focus
();
tape
(5);
}
if(
event
.
keyCode
==
102)
{
document
.
calculatrice
.
c6
.
focus
();
tape
(6);
}
if(
event
.
keyCode
==
103)
{
document
.
calculatrice
.
c7
.
focus
();
tape
(7);
}
if(
event
.
keyCode
==
104)
{
document
.
calculatrice
.
c8
.
focus
();
tape
(8);
}
if(
event
.
keyCode
==
105)
{
document
.
calculatrice
.
c9
.
focus
();
tape
(9);
}
if(
event
.
keyCode
==
107)
{
document
.
calculatrice
.
cplus
.
focus
();
tape
( '+'
);
}
if(
event
.
keyCode
==
109)
{
document
.
calculatrice
.
cmoins
.
focus
();
tape
( '-'
);
}
if(
event
.
keyCode
==
106)
{
document
.
calculatrice
.
cfois
.
focus
();
tape
( '*'
);
}
if(
event
.
keyCode
==
111)
{
document
.
calculatrice
.
cslash
.
focus
();
tape
( '/'
);
}
if(
event
.
keyCode
==
110)
{
document
.
calculatrice
.
cpoint
.
focus
();
tape
( '.'
);
}
if(
event
.
keyCode
==
13)
{
document
.
calculatrice
.
cegal
.
focus
();
egal
();
}
if(
event
.
keyCode
==
46)
{
document
.
calculatrice
.
ac
.
focus
();
document
.
calculatrice
.
ecran
.
value
= ''
;
}
}
document
.
onkeydown
= clavier
;
</script>
</head>
<script type =
"text/javascript">
functioncalcul
(
francs
)
{
document
.
getElementById
( 'result'
).
innerHTML
=
Math .
round
(
parseFloat
(
francs
)
*
6.55957);
}
</script>
<form id =
"form" name= "calculatrice" method =
"post">
<!-- -->
(<gras>this.
value
);
"
/>
width = 25;
height = 25
" onclick= "tape
(
this.
value
)
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "tape
(
this.
value
)
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "
this.
form
.
ecran
.
value
=''
">
width = 25;
height = 25
" onclick= "tape
(
this.
value
)
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "tape
(
this.
value
)
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "carre
()
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "tape
(
this.
value
)
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "tape
(
this.
value
)
">
font-family:
symbol
;width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "tape
(
this.
value
)
">
width =25;
height25 " onclick"tape
(
this.
value
)
">
width= 25;
height =25
" onclick= "egal
()
">
width =25;
height25 " onclick"multiplie
()
">
width= 25;
height =25
" onclick= "inverse
()
">
</form>
Je voudrais y ajouter cette fonction pour transformer les euros en francs:
<script
type =
"text/javascript">
functioncalcul
(
francs
)
{
document
.
getElementById
( 'result'
).
innerHTML
=
Math .
round
(
francs
)
*
6.55957;
}
</script>
<form id =
"form" action= "" method =
"post">
francs :
(<gras>this.
value
);
"
/>
</form>
Je n'arrive pas à le faire fonctionner, pouvez-vous m'aider?
Merci d'avance.