Probelme en javascript
ms
-
fgi -
fgi -
Bonjour,
Exerciec est une calculatrice:
je faire mon essais,Et mon probeleme je ne pas sais pas comment je fait la donction "SQRT"
Voila mon essais:et s'espére mon proleme est claire.merci d'avance
<html>
<head>
<script language="javascript">
var ch='';
function Calcule()
{
document.f.t_af.value=Math.sqrt(document.f.t_af.value);
}
function aff(val)
{
document.f.t_af.value=val;
reserve(document.f.t_af.value);
}
function reserve(ch1)
{
ch=ch+ch1;
document.f.t_af.value=ch;
}
function calc()
{
document.f.t_af.value=eval(document.f.t_af.value);
}
</script>
</head>
<body>
<form name="f">
<table border="1">
<tr>
<td colspan="4"><input type="text" name="t_af" size="110"></td>
</tr>
<tr align="center">
<td><input type="button" name="t7" value=" 7 " onClick="aff(7)"></td>
<td ><input type="button" name="t8" value=" 8 "onClick="aff(8)"></td>
<td ><input type="button" name="t9" value=" 9 "onClick="aff(9)"></td>
<td ><input type="button" name="t/" value=" / "onClick="aff('/')"></td>
</tr>
<tr align="center">
<td><input type="button" name="t4" value=" 4 "onClick="aff(4)"></td>
<td><input type="button" name="t5" value=" 5 "onClick="aff(5)"></td>
<td><input type="button" name="t6" value=" 6 "onClick="aff(6)"></td>
<td><input type="button" name="t*" value=" * "onClick="aff('*')"></td>
</tr>
<tr align="center">
<td><input type="button" name="t1" value=" 1 "onClick="aff(1)"></td>
<td><input type="button" name="t2" value=" 2 "onClick="aff(2)"></td>
<td><input type="button" name="t3" value=" 3 "onClick="aff(3)"></td>
<td><input type="button" name="t-" value=" - "onClick="aff('-')"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="button" name="t0" value=" 0 "onClick="aff(0)"></td>
<td><input type="button" name="t." value=" . " onClick="aff('.')"></td>
<td><input type="button" name="t+" value=" + "onClick="aff('+')"></td>
</tr>
<tr align="center">
<td colspan="3"><input type="reset" name="ton/c" value=" ON/C " size="9"></td>
<td><input type="button" name="t=" value=" = "onClick="calc('=')"></td>
</tr>
<tr align="center">
<td colspan="4" align="center"><input type="button" name="tsqrt" value=" sqrt " onClick="Calcule()">
<input type="button" name="tpow" value=" pow ">
<input type="button" name="tlog" value=" log ">
</td>
</tr>
</table>
</form>
</body>
</head>
</html>
Exerciec est une calculatrice:
je faire mon essais,Et mon probeleme je ne pas sais pas comment je fait la donction "SQRT"
Voila mon essais:et s'espére mon proleme est claire.merci d'avance
<html>
<head>
<script language="javascript">
var ch='';
function Calcule()
{
document.f.t_af.value=Math.sqrt(document.f.t_af.value);
}
function aff(val)
{
document.f.t_af.value=val;
reserve(document.f.t_af.value);
}
function reserve(ch1)
{
ch=ch+ch1;
document.f.t_af.value=ch;
}
function calc()
{
document.f.t_af.value=eval(document.f.t_af.value);
}
</script>
</head>
<body>
<form name="f">
<table border="1">
<tr>
<td colspan="4"><input type="text" name="t_af" size="110"></td>
</tr>
<tr align="center">
<td><input type="button" name="t7" value=" 7 " onClick="aff(7)"></td>
<td ><input type="button" name="t8" value=" 8 "onClick="aff(8)"></td>
<td ><input type="button" name="t9" value=" 9 "onClick="aff(9)"></td>
<td ><input type="button" name="t/" value=" / "onClick="aff('/')"></td>
</tr>
<tr align="center">
<td><input type="button" name="t4" value=" 4 "onClick="aff(4)"></td>
<td><input type="button" name="t5" value=" 5 "onClick="aff(5)"></td>
<td><input type="button" name="t6" value=" 6 "onClick="aff(6)"></td>
<td><input type="button" name="t*" value=" * "onClick="aff('*')"></td>
</tr>
<tr align="center">
<td><input type="button" name="t1" value=" 1 "onClick="aff(1)"></td>
<td><input type="button" name="t2" value=" 2 "onClick="aff(2)"></td>
<td><input type="button" name="t3" value=" 3 "onClick="aff(3)"></td>
<td><input type="button" name="t-" value=" - "onClick="aff('-')"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="button" name="t0" value=" 0 "onClick="aff(0)"></td>
<td><input type="button" name="t." value=" . " onClick="aff('.')"></td>
<td><input type="button" name="t+" value=" + "onClick="aff('+')"></td>
</tr>
<tr align="center">
<td colspan="3"><input type="reset" name="ton/c" value=" ON/C " size="9"></td>
<td><input type="button" name="t=" value=" = "onClick="calc('=')"></td>
</tr>
<tr align="center">
<td colspan="4" align="center"><input type="button" name="tsqrt" value=" sqrt " onClick="Calcule()">
<input type="button" name="tpow" value=" pow ">
<input type="button" name="tlog" value=" log ">
</td>
</tr>
</table>
</form>
</body>
</head>
</html>
A voir également:
- Probelme en javascript
- Telecharger javascript - Télécharger - Langages
- A javascript error occurred in the main process - Forum Windows
- A javaScript error occurred in the main process - Forum Handicap / Accessibilté
- Erreur #125 javascript - Forum Mozilla Firefox
- Javascript arrondi - Forum Javascript
3 réponses
bonjour,
il me semble que la synatxe est correcte, par contre j'ai essaye ton code et rien ne s'affiche ?
il me semble que la synatxe est correcte, par contre j'ai essaye ton code et rien ne s'affiche ?