01/08/2007

Calculatrice

Une petite calculette quelque part sur votre blog ? Pourquoi pas, cela peut toujours servir...

 

Script :

 

<script type="text/javascript">
function calcul ()
{
var x=document.one.txt.value
var y=eval(x)
if (document.one.txt.value)
{
document.one.txt.value=y
}
}
</script>
<script>
function nombre (i)
{
var nb=new Array ("0","1","2","3","4","5","6","7","8","9",".")
var x=document.one.txt.value
document.one.txt.value=""+x+""+nb[i]+""
}
</script>
<script>
function signe (i)
{
var sg=new Array ("/","*","-","+")
var x=document.one.txt.value
document.one.txt.value=""+x+""+sg[i]+""
}
</script>
<script>
function efface ()
{
var x=document.one.txt.value
if (document.one.txt.value)
{
document.one.txt.value=""
}
}
</script>
<script>
function carre ()
{
var x=document.one.txt.value
if (document.one.txt.value)
{
document.one.txt.value=x*x
}
}
</script>
<script>
function inverse ()
{
var x=document.one.txt.value
if (document.one.txt.value)
{
document.one.txt.value=1/x
}
}
</script>
<script>
function cube ()
{
var x=document.one.txt.value
if (document.one.txt.value)
{
document.one.txt.value=x*x*x
}
}
</script>
<form name="one">
<table width="196" height="175" border="0" bgcolor="#CCCCCC">
  <tr>
    <th height="43" colspan="3" scope="col"><input name="txt" type="text" size="25" /></th>
  </tr>
  <tr>
    <th width="38" height="74" scope="row"><input type="button" value="x^3" name="boutton218" onclick="javascript:cube()" />
      <input type="button" value="x^2" name="boutton2" onclick="javascript:carre()" />
      <input type="button" value="x^ -1" name="boutton217" onclick="javascript:inverse()" /></th>
    <td width="99"><p align="center">
      <input type="button" value=" 7 " name="boutton22" onclick="javascript:nombre(7)" />
      <input type="button" value=" 8 " name="boutton23" onclick="javascript:nombre(8)" />
      <input type="button" value=" 9 " name="boutton24" onclick="javascript:nombre(9)" /><input type="button" value=" 4 " name="boutton25" onclick="javascript:nombre(4)" />
        <input type="button" value=" 5 " name="boutton26" onclick="javascript:nombre(5)" />
        <input type="button" value=" 6 " name="boutton27" onclick="javascript:nombre(6)" /><input type="button" value=" 1 " name="boutton28" onclick="javascript:nombre(1)" />
      <input type="button" value=" 2 " name="boutton29" onclick="javascript:nombre(2)" />
      <input type="button" value=" 3 " name="boutton210" onclick="javascript:nombre(3)" />
        <input type="button" value="  0  " name="boutton211" onclick="javascript:nombre(0)" />
        <input type="button" value=" . " name="boutton212" onclick="javascript:nombre(10)" />
    </p>      </td>
    <td width="45"><p align="center">
      <input type="button" value=" + " name="boutton213" onclick="javascript:signe(3)" />
        <input type="button" value=" - " name="boutton215" onclick="javascript:signe(2)" />
        <input type="button" value=" : " name="boutton216" onclick="javascript:signe(0)" />
        <input type="button" value=" x " name="boutton2162" onclick="javascript:signe(1)" />
      </p>      </td>
  </tr>
  <tr>
    <th height="26" colspan="3" scope="row"><p align="right">
      <input name="boutton214" type="button" onclick="javascript:efface()" value="  AC  " />
      <input name="boutton" type="button" onclick="javascript:calcul()" value="  exe  " />
    </p></th>
    </tr>
</table>
</form>

01:04 Écrit par aidesupport dans Scripts | Lien permanent | Commentaires (0) |  Facebook |

Les commentaires sont fermés.