Pagine

martedì 30 dicembre 2008

ubuntu

Dieci buoni motivi per passare a ubuntu
(se sei un utente di Windows)
  1. E' gratis (no, non come la copia craccata che hai di windows. Questo si scarica, si scrive su un cd, si prova dal lettore cd, se piace si installa ed è tuo!)
  2. E' legale (lo so che hai sempre fatto finta di non sapere che farsi prestare un cd pirata di win xp con i relativi codici era illegale.)
  3. E' pieno di programmi gratuiti (non come quelli craccati che scarichi con Emule.)
  4. E' molto più leggero di Windows (gira sul mio Pentium 3 che manco una Ferrari ...)
  5. Non devi necessariamente rinunciare a windows (durante l'installazione ti da' la possibilità di creare una partizione per se ed una per win. Ad ogni avvio sceglierai con quale S.O. partire. )
  6. Ha una comunità vastissima di utenti che risponde a tutti i tuoi quesiti.
  7. Ha una interfaccia grafica che se ne fotte di Windows
  8. Avere Linux sul PC farà di te un tizio/a più interessante che ci capisce di cose informatiche.
  9. Ubuntu ti costringe ad usare nuovamente il cervello.(Visto che gli amici di Bill Gates cercano di mettertelo a riposo.)
  10. Puoi scaricarlo direttamente da QUI'.

sabato 20 dicembre 2008

Calcolatrice javascript 2


Nel post precedente avevamo costruito una semplice calcolatrice che ci restituiva dei calcoli in base ai numeri inseriti nella caselle di testo. Questa volta, spero in maniera semplice ed esaustiva, implementiamo il progetto precedente con l'ausilio di un tastierino numerico.


Il codice:


<html><head>


<script language="javascript">

function uno(){document.forms.g.txt1.value=document.forms.g.txt1.value +1;}

function due(){document.forms.g.txt1.value=document.forms.g.txt1.value +2;}

function tre(){document.forms.g.txt1.value=document.forms.g.txt1.value +3;}

function qua(){document.forms.g.txt1.value=document.forms.g.txt1.value +4;}

function cin(){document.forms.g.txt1.value=document.forms.g.txt1.value +5;}

function sei(){document.forms.g.txt1.value=document.forms.g.txt1.value +6;}

function set(){document.forms.g.txt1.value=document.forms.g.txt1.value +7;}

function ott(){document.forms.g.txt1.value=document.forms.g.txt1.value +8;}

function nov(){document.forms.g.txt1.value=document.forms.g.txt1.value +9;}

function zer(){document.forms.g.txt1.value=document.forms.g.txt1.value +0;}

function vir(){document.forms.g.txt1.value=document.forms.g.txt1.value +'.';document.forms.g.virgola.disabled=true;}

//ad ogni tasto ho assegnato un numero ed alla virgola aggiungo la disabilitazione del tasto stesso una volta premuto


//adesso le operazioni che assegnano un segno, riabilitani il tasto della virgola e ripuliscono il campo di testo


function piu(){document.forms.g.txtsegno.value='+';document.forms.g.virgola.disabled=false;document.forms.g.txt2.value=document.forms.g.txt1.value;document.forms.g.txt1.value="";}

function men(){document.forms.g.txtsegno.value='-';document.forms.g.virgola.disabled=false;document.forms.g.txt2.value=document.forms.g.txt1.value;document.forms.g.txt1.value="";}

function per(){document.forms.g.txtsegno.value='X';document.forms.g.virgola.disabled=false;document.forms.g.txt2.value=document.forms.g.txt1.value ;document.forms.g.txt1.value="";}

function div(){document.forms.g.txtsegno.value=':';document.forms.g.virgola.disabled=false;document.forms.g.txt2.value=document.forms.g.txt1.value;document.forms.g.txt1.value="";}

//infine l'uguale che fa partire il calcolo


function ugu(){

Segno=document.forms.g.txtsegno.value;

if (Segno=="+"){document.forms.g.txt3.value=document.forms.g.txt1.value;document.forms.g.ris.value=eval(document.forms.g.txt2.value)+eval(document.forms.g.txt3.value);

}

if (Segno=="-"){document.forms.g.txt3.value=document.forms.g.txt1.value;document.forms.g.ris.value=eval(document.forms.g.txt2.value)- eval(document.forms.g.txt3.value);}

if (Segno=="X"){document.forms.g.txt3.value=document.forms.g.txt1.value;document.forms.g.ris.value=document.forms.g.txt2.value * document.forms.g.txt3.value}

if (Segno==":"){document.forms.g.txt3.value=document.forms.g.txt1.value;document.forms.g.ris.value=document.forms.g.txt2.value / document.forms.g.txt3.value}

document.forms.g.txt1.value="";

document.forms.g.virgola.disabled=false;

}

function radice(){Txt1=document.forms.g.txt1.value;Rad=Math.sqrt(Txt1);document.forms.g.ris.value=Rad}



</script>



<title>Freecalc 1.0.1 </title>

</head>


<!--inserisco l'html del form-->


<body>

<form name="g">

<table width="150" border="0" cellpadding="2" cellspacing="2" bgcolor="#FF9900">

<caption align="top">

Freecalc1.0.1

</caption>

<tr>

<th colspan="4" align="left" scope="col"><input type="text" name="txt1" size="24"/></th>

</tr>

<tr bgcolor="#FFFFFF">

<td ><input name="Input" type="button" value=" 7 " onclick="set()" /></td>

<td ><input name="Input" type="button" value=" 8 " onclick="ott()"/></td>

<td ><input name="Input" type="button" value=" 9 " onclick="nov()"/></td>

<td ><input name="Input2" type="button" value=" + " onclick="piu()"/></td>

</tr>

<tr bgcolor="#FFFFFF">

<td ><input name="Input" type="button" value=" 4 " onclick="qua()"/></td>

<td ><input name="Input" type="button" value=" 5 " onclick="cin()"/></td>

<td ><input name="Input" type="button" value=" 6 " onclick="sei()"/></td>

<td><input name="Input3" type="button" value=" - " onclick="men()"/></td>

</tr>

<tr bgcolor="#FFFFFF">

<td ><input name="Input" type="button" value=" 1 " onclick="uno()" onkeypress=""/></td>

<td ><input name="Input" type="button" value=" 2 " onclick="due()"/></td>

<td ><input name="Input" type="button" value=" 3 " onclick="tre()"/></td>

<td><input name="Input4" type="button" value=" X " onclick="per()"/></td>

</tr>

<tr bgcolor="#FFFFFF">

<td ><input name="Input" type="button" value=" 0 " onclick="zer()"/></td>

<td ><input name="virgola" type="button" value=" , " onclick="vir()"/></td>

<td ><input name="Input" type="button" value=" = " onclick="ugu()"/></td>

<td><input name="Input5" type="button" value=" : " onclick="div()"/></td>

</tr>

<tr bgcolor="#FFFFFF">

<td colspan="4"><input name="txt2" type="text" value=" 0 " size="9" maxlength="9" readonly="true"/>

<input name="txtsegno" type="text" class="Stile1" size="2" maxlength="1" readonly="true" />

<input name="txt3" type="text" value="0" size="9" maxlength="9" readonly="true"/>

=</td>

</tr>

<tr bgcolor="#FFFFFF">

<td colspan="2"><input name="ris" type="text" size="10" maxlength="5" readonly="true"/></td>

<td><input name="Input6" type="reset" value=" C " /></td>

<td><input name="Input7" type="button" value=" Rq" title="Radice quadrata" onclick="radice()"/></td>

</tr>

</table>

</form>


</body><html>


Clicca quì per vedere l'esempio.


oppureC.I.P.(copia, incolla ,prova)

Calcolatrice javascript


Torno a postare di fretta e su richiesta specifica.


Volevi una calcolatrice da inserire tra le tue pagine web?


La volevi in javascript?


Copia e incolla questo subito dopo body.


<script language="javascript">




function somma(){


//inizializzo le due variabili Txt1 e Txt2


Txt1=eval(document.forms.g.txt1.value);


Txt2=eval(document.forms.g.txt2.value);


//attribuisco il valore della loro somma alla variabile Ris


Ris=(Txt1+Txt2);document.forms.g.ris.value=Ris}




function sottrai(){


//Ripeto le operazioni di prima


//solo che questa volta sottraggo


Txt1=eval(document.forms.g.txt1.value);


Txt2=eval(document.forms.g.txt2.value);


Ris=(Txt1-Txt2);document.forms.g.ris.value=Ris}




function dividi(){


//idem per la divisione


Txt1=eval(document.forms.g.txt1.value);



Txt2=eval(document.forms.g.txt2.value);


Ris=(Txt1/Txt2);document.forms.g.ris.value=Ris}




function moltiplica(){


//idem per la moltiplicazione


Txt1=eval(document.forms.g.txt1.value);


Txt2=eval(document.forms.g.txt2.value);


Ris=(Txt1*Txt2);document.forms.g.ris.value=Ris}




function radice () {


//.....e per la radice quadrata


Txt1=document.forms.g.txt1.value;


Ris=Math.sqrt(Txt1);document.forms.g.ris.value=Ris}

</script>


A questo punto mi costruisco un bel form. Ecco l'HTML!


(da inserire subito dopo il codice javascript)


<form name="g">

<table width="493" border="0" cellpadding="3" cellspacing="3" bgcolor="#FF6600">

<caption align="top">

La Mia Calcolatrice


</caption>

<tr bgcolor="#FFFFFF">

<td width="14%"><input name="txt1" type="text" size="10" maxlength="10" /></td>

<td width="47%" align="center"><input name="+" type="button" value="+" onClick="somma()"/><input name="-" type="button" value="-" onClick="sottrai()"/><input name=":" type="button" value=":" onClick="dividi()"/><input name="x" type="button" value="x" onClick="moltiplica()"/>



<input type="button" name="RQ" value="RQ" title="Radice Quadrata" onclick="radice()"/>



<td width="14%"><input name="txt2" type="text" size="10" maxlength="10" /></td>

<td width="5%" align="center"> = </td>

<td width="20%"><input name="ris" type="text" size="10" maxlength="10" readonly="true" /></td>

</tr>



</table>


</form>


C.I.P (copia incolla prova)


oppure clicca qui per vedere in azione la mini calcolatrice.


Alla prossima